Using unit tests
Unit tests are used to test smaller chunks of functionality. In this recipe, we'll see an example of this.
How to do it...
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.
- In a new project, create a new
first-last.js
file in themodels
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
andlastName ...
Get Ember.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.