Skip to content

Instantly share code, notes, and snippets.

@andrewmp1
Last active December 15, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewmp1/5219196 to your computer and use it in GitHub Desktop.
Save andrewmp1/5219196 to your computer and use it in GitHub Desktop.
Ember testing helper
var testing = function(app){
var container = app.__container__,
appController = container.lookup('controller:application'),
router = container.lookup("router:main");
var helper = {
path: function(){
return appController.get('currentPath');
},
routeName: function(){
return helper.path().split('.').pop();
},
route: function(){
return container.lookup('route:' + helper.routeName());
},
controller: function(){
return helper.route().get('controller');
},
model: function(){
return helper.route().get('currentModel');
},
transitionTo: function(){
return router.transitionTo.apply(router, arguments);
},
send: function(){
return router.send.apply(router, arguments);
},
lookup: function(path) {
return container.lookup(path);
},
activeView: function(name) {
return router._lookupActiveView(name);
},
lastSetURL: function(){
return router.location.lastSetURL;
},
navigateTo: function(path){
window.location.replace(path);
}
};
return helper;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment