Created
July 18, 2013 04:42
-
-
Save kamal/6026760 to your computer and use it in GitHub Desktop.
within helper for ember-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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