测试服务时angular.mock.inject中的错误

时间:2015-05-12 10:44:59

标签: angularjs jasmine inject

我想在AngularJS中对服务进行测试,但是注射器一直存在问题。

这是服务:

var projectApp = angular.module("projectApp", []);

projectApp.service("workTimeService", function(){

    this.workHours = function(workHours){
        return workHours;
    }
}

以下是测试:

describe("Unit: Testing services", function(){
    var workTimeService;

    beforeEach(function(){
        module("projectApp");
    });
    beforeEach(inject(function(_workTimeService_){
        workTimeService = _workTimeService_;
    }));

    it('Should have funtion', function(){
        expect(angular.isFunction(workTimeService.workHours)).toBe(true);
    });
});

我就像在教程中一样,但jasmine说workTimeService未定义。

0 个答案:

没有答案