Hi,
it's pretty hard to find examples of unit tests which contain the config
phase of an Angular app. Most tutorial, apps or blog articles seem to avoid
this topics. This is confusing for me (and
others<https://stackoverflow.com/questions/18983280/unit-testing-the-config-phase-in-angularjs>).
The main problem is, that you can't easily mock and inject providers.
An example:
angular.module('test', [])
.config(function($urlRouterProvider) {
$urlRouterProvider.otherwise('/test');
});
I would really like to have a test like this:
it('should configure a default route', function() {
// a previously mocked $urlRouterProvider
expect($urlRouterProvider.otherwise).toHaveBeenCalled();
});
But I can't mock $urlRouterProvider. It seems like the Angular project
itself test this via using and manipulating $location and $router, but that
is fairly complex (and unnecessary?) and looks more like an integration
test or whatever than a unit test.
Is there an easier way to write unit tests for the config phase?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.