我正在寻找在Ember.js应用程序中对路线进行单元测试的最佳解决方案.我找到了两个解决方案,我希望你能告诉我什么对你最好.这两个实现可以在这里找到:http://jsbin.com/URaKULa/1/edit
//=====================================
// Source :
//=====================================
App = Em.Application.create({
});
App.UserEditRoute = Ember.Route.extend({
model: function () {
// here we tell the route to use its parent model
return this.modelFor('user');
},
activate: function () {
this.controllerFor('user').set('editMode', true);
},
deactivate: function () {
this.controllerFor('user').set('editMode', false);
},
events: {
goBack: function () {
this.transitionTo('user');
}
}
});
// defer readiness and set location's router to none in order to stop main application initialization
App.setupForTesting();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//=====================================
// Test : …Run Code Online (Sandbox Code Playgroud)