This is a short talk given at the Ember.js Munich July Meetup. It briefly explains the basics of unit testing in Ember.js and gives some examples and details
8. About Testing
• Unit Testing
• Verify, that isolated chunks of functionality work
• Don't worry about their dependencies
9. About Testing
• Unit Testing
• Verify, that isolated chunks of functionality work
• Don't worry about their dependencies
• Integration Testing
• Test user interaction and application flow
27. Testing Components IV
test("it sets value to selected object", function() {
expect(2);
this.append();
component.set('content', simpleContent);
!
// open options by clicking on the element
click('.select2-choice');
// then select an option
click('.select2-results li:nth-child(3)', 'body');
!
andThen(function() {
equal(component.get(‘value’),
simpleContent[2], "selects correct item");
equal($(‘.select2-chosen').text(),
simpleContent[2].text, "has correct text");
});
});
28. Testing Components V
test("it wraps the content in <pre><code>", function() {
expect(2);
// create wrapper view with template
var component = Ember.View.extend({
template: Ember.Handlebars
.compile('{{#highlight-code}}hello!{{/highlight-code}}')
}).create();
!
Ember.run(function() {
component.appendTo('#ember-testing');
});
!
ok(component.$("pre").length, "pre exists");
!
ok(component.$("pre > code").length, "pre > code exists");
});