February 2016
Beginner to intermediate
308 pages
5h 46m
English
Unit tests are used to test smaller chunks of functionality. In this recipe, we'll see an example of this.
In this example, we'll create a simple Ember.Object with a computed property. We'll test this computed property and assert if the value returned is correct or not.
first-last.js file in the models folder:// app/models/first-last.js
import Ember from 'ember';
export default Ember.Object.extend({
firstName: 'John',
lastName: 'Smith',
fullName: Ember.computed('firstName', 'lastName', function() {
const firstName = this.get('firstName');
const lastName= this.get('lastName');
return `Full Name: ${firstName} ${lastName}`;
})
});In this file, we have two properties, firstName and lastName ...
Read now
Unlock full access