diff --git a/lib/ember-test-helpers/test-module-for-component.js b/lib/ember-test-helpers/test-module-for-component.js index 4318a2410..466cab083 100644 --- a/lib/ember-test-helpers/test-module-for-component.js +++ b/lib/ember-test-helpers/test-module-for-component.js @@ -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; }; diff --git a/tests/test-module-for-integration-test.js b/tests/test-module-for-integration-test.js index 385b0c1ae..78e76e604 100644 --- a/tests/test-module-for-integration-test.js +++ b/tests/test-module-for-integration-test.js @@ -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('{{foo}}{{bar}}') + }) + }); + } +}); + +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,