Skip to content

Commit

Permalink
revert part of emberjs#349 - only new function read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Apr 17, 2018
1 parent 7f9a3d0 commit eeb591c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 45 deletions.
50 changes: 19 additions & 31 deletions addon-test-support/@ember/test-helpers/setup-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,29 @@ export default function(context, options = {}) {
writable: false,
});

Object.defineProperty(context, 'set', {
value(key, value) {
let ret = run(function() {
return set(context, key, value);
});

return ret;
},
writable: false,
});
context.set = function(key, value) {
let ret = run(function() {
return set(context, key, value);
});

Object.defineProperty(context, 'setProperties', {
value(hash) {
let ret = run(function() {
return setProperties(context, hash);
});
return ret;
};

return ret;
},
writable: false,
});
context.setProperties = function(hash) {
let ret = run(function() {
return setProperties(context, hash);
});

Object.defineProperty(context, 'get', {
value(key) {
return get(context, key);
},
writable: false,
});
return ret;
};

Object.defineProperty(context, 'getProperties', {
value(...args) {
return getProperties(context, args);
},
writable: false,
});
context.get = function(key) {
return get(context, key);
};

context.getProperties = function(...args) {
return getProperties(context, args);
};

let resume;
context.resumeTest = function resumeTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ export default function setupRenderingContext(context) {
// these methods being placed on the context itself will be deprecated in
// a future version (no giant rush) to remove some confusion about which
// is the "right" way to things...
Object.defineProperty(context, 'render', { value: render, writable: false });
Object.defineProperty(context, 'clearRender', {
value: clearRender,
writable: false,
});
context.render = render;
context.clearRender = clearRender;

if (global.jQuery) {
Object.defineProperty(context, '$', { value: jQuerySelector, writable: false });
context.$ = jQuerySelector;
}

// When the host app uses `setApplication` (instead of `setResolver`) the event dispatcher has
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/setup-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ module('setupContext', function(hooks) {
);
});

overwriteTest(context, 'set');
overwriteTest(context, 'setProperties');
overwriteTest(context, 'get');
overwriteTest(context, 'getProperties');

test('it calls setContext with the provided context', function(assert) {
assert.equal(getContext(), context);
});
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/setup-rendering-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ module('setupRenderingContext', function(hooks) {
assert.strictEqual(this.element, originalElement, 'this.element is stable');
});

overwriteTest('render');
overwriteTest('clearRender');

(hasjQuery() ? test : skip)('this.$ is exposed when jQuery is present', async function(assert) {
await this.render(hbs`<p>Hello!</p>`);

Expand Down

0 comments on commit eeb591c

Please sign in to comment.