Skip to content

Instantly share code, notes, and snippets.

@ilyakam
Last active November 26, 2016 09:53
Show Gist options
  • Select an option

  • Save ilyakam/553aca6ebfdbfd62ccd76f87d1e687f8 to your computer and use it in GitHub Desktop.

Select an option

Save ilyakam/553aca6ebfdbfd62ccd76f87d1e687f8 to your computer and use it in GitHub Desktop.
$routeProvider
.when('/', {
resolve: {
user: function() {
return 'user_id';
}
}
});
beforeEach(module('ngRoute', function($routeProvider) {
$route = $routeProvider;
spyOn($route, 'when');
}));
beforeEach(function() {
module('some-module');
inject();
})
describe('some route', function() {
it('should resolve the user', function() {
var userTester = {
asymmetricMatch: function(user) {
return user() === 'user_id';
}
};
expect($route.when)
.toHaveBeenCalledWith('/', jasmine.objectContaining({
resolve: {user: userTester}
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment