Skip to content

Commit

Permalink
Merge pull request #68 from CodeOfficer/set-properties
Browse files Browse the repository at this point in the history
allow getProperties and setProperties for component integration tests
  • Loading branch information
rwjblue committed Jul 20, 2015
2 parents f5fba33 + 4105cd2 commit 919c654
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,21 @@ export default TestModule.extend({
});
};

context.setProperties = function(hash) {
Ember.run(function() {
Ember.setProperties(context, hash);
});
};

context.get = function(key) {
return Ember.get(context, key);
};

context.getProperties = function() {
var args = Array.prototype.slice.call(arguments);
return Ember.getProperties(context, args);
};

context.on = function(actionName, handler) {
module.actionHooks[actionName] = handler;
};
Expand Down
31 changes: 31 additions & 0 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,37 @@ test('it has working events', function() {
equal(this.$('.value').text(), '1');
});

moduleForComponent('Component Integration Tests: context', {
integration: true,
beforeSetup: function() {
setResolverRegistry({
'component:my-component': Ember.Component.extend({
layout: Ember.Handlebars.compile('<span class="foo">{{foo}}</span><span class="bar">{{bar}}</span>')
})
});
}
});

test('it can set and get properties', function() {
this.set('foo', 1);
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({
foo: 1,
bar: 2
});
this.render('{{my-component foo=foo bar=bar}}');
var properties = this.getProperties('foo', 'bar');
equal(properties.foo, '1');
equal(properties.bar, '2');
equal(this.$('.foo').text(), '1');
equal(this.$('.bar').text(), '2');
});

var origDeprecate;
moduleForComponent('Component Integration Tests: implicit views are not deprecated', {
integration: true,
Expand Down

0 comments on commit 919c654

Please sign in to comment.