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

Test coverage for render during component integration test setup #42

Closed
wants to merge 1 commit into from
Closed
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
44 changes: 44 additions & 0 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,47 @@ test('it accepts precompiled templates', function() {
this.render(Ember.Handlebars.compile("<span>Hello</span>"));
equal(this.$('span').text(), 'Hello');
});

test('it supports DOM events', function() {
setResolverRegistry({
'component:my-component': Ember.Component.extend({
value: 0,
layout: Ember.Handlebars.compile(`
<span class='target'>Click to increment!</span>
<span class='value'>{{value}}</span>
`),
incrementOnClick: Ember.on('click', function() {
this.incrementProperty('value');
})
})
});
this.render('{{my-component}}');
this.$('.target').click();
equal(this.$('.value').text(), '1');
});

moduleForComponent('Component Integration Tests: render during setup', {
integration: true,
beforeSetup: function() {
setResolverRegistry({
'component:my-component': Ember.Component.extend({
value: 0,
layout: Ember.Handlebars.compile(`
<span class='target'>Click to increment!</span>
<span class='value'>{{value}}</span>
`),
incrementOnClick: Ember.on('click', function() {
this.incrementProperty('value');
})
})
});
},
setup() {
this.render('{{my-component}}');
}
});

test('it has working events', function() {
this.$('.target').click();
equal(this.$('.value').text(), '1');
});
7 changes: 1 addition & 6 deletions tests/test-support/qunit-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { getContext } from 'ember-test-helpers';

function resetViews() {
Ember.View.views = {};
}

export default function test(testName, callback) {
function wrapper() {
var context = getContext();

resetViews();
var result = callback.call(context);

function failTestOnPromiseRejection(reason) {
Expand All @@ -22,4 +17,4 @@ export default function test(testName, callback) {
}

QUnit.test(testName, wrapper);
}
}