Skip to content

Instantly share code, notes, and snippets.

@himangshuj
Last active September 3, 2019 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himangshuj/8142045 to your computer and use it in GitHub Desktop.
Save himangshuj/8142045 to your computer and use it in GitHub Desktop.
how to test $urlRouterProvider for angularjs
(function (ng, app) {
ng.module('sokratik.app.container', [
'ui.router',
])
.config(function myAppConfig($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/start');
})
.controller('AppCtrl', ["$scope", "$location", function AppCtrl($scope, $location) {
}]);
})(angular, "sokratik.app.container");
describe('AppCtrl', function () {
var $location, $scope, AppCtrl;
beforeEach(module('sokratik.app.container'));
beforeEach(inject(function ($controller, _$location_, $rootScope) {
$location = _$location_;
$scope = $rootScope.$new();
AppCtrl = $controller('AppCtrl', { $location: $location, $scope: $scope });
}));
it("initialization checks", inject(function ($urlRouter) {
$scope.$emit("$locationChangeSuccess");
expect($location.path()).toBe("/start");
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment