###Router
App.Router.map( function() { this.resource( "mobileApps", function() { ... });
App.MobileAppsIndexRoute = App.Route.extend({
...
});
###Controller
App.LoginController = Ember.ObjectController.extend({ ... login: function() { var that = this; ... //in a success callback that.transitionToRoute( "mobileApps" ); //works ok when not running as a test // throws this error: Uncaught TypeError: Cannot read property 'transitionToRoute' of null, when testing } ... });
###Test
//setup Ember.testing = true;
App.rootElement = '#ember-testing'; App.setupForTesting(); App.injectTestHelpers();
module('App.LoginController', { setup: function() { App.reset(); Ember.run(this, function() { this.model = App.User.create({}); this.controller = App.LoginController.create({ content: this.model, loginIn: true }); }); } });
test( "blah", function() { Ember.run( this, function() { var that = this; this.controller.login(); //call the login function // throws this error: Uncaught TypeError: Cannot read property 'transitionToRoute' of null wait().then( function() { ... // do some test code }); }); });