I'm writing a router and using Karma for TDD. I'm all good with the setup and unit testing with Mocha/Chai/Sinon. My question is, using Karma, how can I test that the browser's location path has changed?
In my router, I'm doing:
window.history.pushState(route.params, route.title, route.path);
And this of course changes the location in the browser when NOT using Karma. In my unit test, I was expecting something like:
it('should map deps and execute on navigation', function() {
app
.route('/profile', 'profile')
.controller('profile', [function() {
expect(location.pathname).to.equal('/profile');
}])
.navigate('/profile');
});
But location.pathname equates to the Karma '/context.html'
How can I assert the location pathname was changed using Karma? Should I mock window?
Aucun commentaire:
Enregistrer un commentaire