From 394ea91e4e5613e1cb79c0f02f0d174734e08941 Mon Sep 17 00:00:00 2001 From: Trent Willis Date: Thu, 10 Dec 2015 17:20:27 -0800 Subject: [PATCH] Return passed in value for set and setProperties in integration test --- .../test-module-for-component.js | 18 +++++++++++---- tests/test-module-for-integration-test.js | 22 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/ember-test-helpers/test-module-for-component.js b/lib/ember-test-helpers/test-module-for-component.js index 80dabbc63..ab163442b 100644 --- a/lib/ember-test-helpers/test-module-for-component.js +++ b/lib/ember-test-helpers/test-module-for-component.js @@ -1,6 +1,7 @@ import TestModule from './test-module'; import Ember from 'ember'; import { getResolver } from './test-resolver'; +import hasEmberVersion from './has-ember-version'; export default TestModule.extend({ isComponentTestModule: true, @@ -160,15 +161,23 @@ export default TestModule.extend({ }; context.set = function(key, value) { - Ember.run(function() { - Ember.set(context, key, value); + var ret = Ember.run(function() { + return Ember.set(context, key, value); }); + + if (hasEmberVersion(2,0)) { + return ret; + } }; context.setProperties = function(hash) { - Ember.run(function() { - Ember.setProperties(context, hash); + var ret = Ember.run(function() { + return Ember.setProperties(context, hash); }); + + if (hasEmberVersion(2,0)) { + return ret; + } }; context.get = function(key) { @@ -183,6 +192,7 @@ export default TestModule.extend({ context.on = function(actionName, handler) { module.actionHooks[actionName] = handler; }; + context.send = function(actionName) { var hook = module.actionHooks[actionName]; if (!hook) { diff --git a/tests/test-module-for-integration-test.js b/tests/test-module-for-integration-test.js index 8a9780743..8e5679695 100644 --- a/tests/test-module-for-integration-test.js +++ b/tests/test-module-for-integration-test.js @@ -10,7 +10,6 @@ function moduleForComponent(name, description, callbacks) { qunitModuleFor(module); } - moduleForComponent('Component Integration Tests', { integration: true, beforeSetup: function() { @@ -157,17 +156,32 @@ moduleForComponent('Component Integration Tests: context', { }); test('it can set and get properties', function() { - this.set('foo', 1); + var setResult = this.set('foo', 1); + + if (hasEmberVersion(2,0)) { + equal(setResult, '1'); + } else { + equal(setResult, undefined); + } + this.render('{{my-component foo=foo}}'); equal(this.get('foo'), '1'); equal(this.$('.foo').text(), '1'); }); test('it can setProperties and getProperties', function() { - this.setProperties({ + var hash = { foo: 1, bar: 2 - }); + }; + var setResult = this.setProperties(hash); + + if (hasEmberVersion(2,0)) { + deepEqual(setResult, hash); + } else { + equal(setResult, undefined); + } + this.render('{{my-component foo=foo bar=bar}}'); var properties = this.getProperties('foo', 'bar'); equal(properties.foo, '1');