From eeb591c7fd4e35ce3a711d3f7f41b1ebea3c49b4 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Tue, 17 Apr 2018 15:33:48 -0700 Subject: [PATCH] revert part of #349 - only new function read-only --- .../@ember/test-helpers/setup-context.js | 50 +++++++------------ .../test-helpers/setup-rendering-context.js | 9 ++-- tests/unit/setup-context-test.js | 5 -- tests/unit/setup-rendering-context-test.js | 3 -- 4 files changed, 22 insertions(+), 45 deletions(-) diff --git a/addon-test-support/@ember/test-helpers/setup-context.js b/addon-test-support/@ember/test-helpers/setup-context.js index b8248724e..1587c85f8 100644 --- a/addon-test-support/@ember/test-helpers/setup-context.js +++ b/addon-test-support/@ember/test-helpers/setup-context.js @@ -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() { diff --git a/addon-test-support/@ember/test-helpers/setup-rendering-context.js b/addon-test-support/@ember/test-helpers/setup-rendering-context.js index 576644294..c83669da3 100644 --- a/addon-test-support/@ember/test-helpers/setup-rendering-context.js +++ b/addon-test-support/@ember/test-helpers/setup-rendering-context.js @@ -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 diff --git a/tests/unit/setup-context-test.js b/tests/unit/setup-context-test.js index fd4a29e9a..a0a79a64f 100644 --- a/tests/unit/setup-context-test.js +++ b/tests/unit/setup-context-test.js @@ -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); }); diff --git a/tests/unit/setup-rendering-context-test.js b/tests/unit/setup-rendering-context-test.js index f835ad70a..d7e804cd8 100644 --- a/tests/unit/setup-rendering-context-test.js +++ b/tests/unit/setup-rendering-context-test.js @@ -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`

Hello!

`);