Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return passed in value for set and setProperties in integration test #132

Merged
merged 1 commit into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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