Last active
September 3, 2019 17:18
-
-
Save himangshuj/8142045 to your computer and use it in GitHub Desktop.
how to test $urlRouterProvider for angularjs
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
(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"); |
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
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