February 2016
Beginner to intermediate
308 pages
5h 46m
English
Controllers should be tested in your application. In this recipe, we'll test some basic actions from a controller.
index controller:
$ ember g controller index
This creates a new controller called index.
// app/controllers/index.js
import Ember from 'ember';
export default Ember.Controller.extend({
myValue: 'value',
actions:{
pressed(value){
this.set('myValue',value);
}
}
});This controller has one property named myValue. Another action called pressed changes the value of myValue to whatever value is passed in the function.
// tests/unit/controllers/index-test.js import { moduleFor, ...Read now
Unlock full access