茉莉花单元测试投掷错误:未知提供者:$ urlRouterProvider

时间:2015-07-08 05:13:46

标签: karma-jasmine

    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 be true', inject(function($rootScope){
            scope = $rootScope.$new();
            var ctrl = $controller('mainCtrl', { $scope: scope, $urlRouterProvider: urlRouterProviderMock });
        }));
    });
});

0 个答案:

没有答案