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

allow getProperties and setProperties for component integration tests #68

Merged
merged 1 commit into from
Jul 20, 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
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