Skip to content

Commit

Permalink
Return passed in value for set and setProperties in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Trent Willis committed Dec 11, 2015
1 parent b632138 commit 394ea91
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
18 changes: 14 additions & 4 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
22 changes: 18 additions & 4 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function moduleForComponent(name, description, callbacks) {
qunitModuleFor(module);
}


moduleForComponent('Component Integration Tests', {
integration: true,
beforeSetup: function() {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 394ea91

Please sign in to comment.