Jasmine unit testing throwing error :Unknown provider : $urlRouterProvider -
angular.module('myapp.mainview', []) .config([ '$urlrouterprovider', '$stateprovider', maingridconfig ]) .controller('homectrl',[ '$scope', '$location', '$timeout','quotesservice','base64service', mainpagegrid ]); function maingridconfig($urlrouterprovider, $stateprovider) { 'use strict'; $urlrouterprovider.otherwise('/'); $stateprovider.state('home', { url : '/', templateurl : 'template/home.html', controller : 'homectrl' }); } function mainpagegrid($scope, $location, $timeout,quotesservice,base64service) { ..... }
describe('controller:homectrl',function(){ var $controller, scope; var urlrouterprovidermock = { }; beforeeach(function(){ module('myapp.mainview'); }); beforeeach(function () { module(function ($provide) { $provide.value('$urlrouterprovider', urlrouterprovidermock); }); }); beforeeach(inject(function(_$controller_){ $controller = _$controller_; })); describe('test function',function(){ it('should true', inject(function($rootscope){ scope = $rootscope.$new(); var ctrl = $controller('mainctrl', { $scope: scope, $urlrouterprovider: urlrouterprovidermock }); })); }); });
Comments
Post a Comment