Skip to content

Instantly share code, notes, and snippets.

@kamal
Created July 18, 2013 04:42
Show Gist options
  • Save kamal/6026760 to your computer and use it in GitHub Desktop.
Save kamal/6026760 to your computer and use it in GitHub Desktop.
within helper for ember-test
Ember.Test.registerHelper('within', function(app, withinContext, callback){
var originalFind = window.find;
window.find = function(selector, context) {
return originalFind.call(app, selector, withinContext);
};
callback.call();
window.find = originalFind;
});
visit('/')
.then(function() {
within('nav.top-bar', function() {
equal(find('a:contains(Home)').attr('href'), '/', 'Home link in top navbar');
equal(find('a:contains(About)').attr('href'), '/about', 'About link in top navbar');
});
within('nav.footer', function() {
equal(find('a:contains(Home)').attr('href'), '/', 'Home link in footer');
equal(find('a:contains(About)').attr('href'), '/about', 'About link in footer');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment