var testappservice = angular.module('testappservicemodule',[])
testappservice.factory('testappService',function(){
return function(){
var add = function(){
return 'added';
}
return function(){
add : add
}
}
})
describe('testappService factory Testcases', function() {
var testappService;
beforeEach(function () {
angular.mock.module('testappservicemodule');
});
beforeEach(inject(function(_testappService_) {
testappService = _testappService_;
}));
it('testappService should be defined', function() {
expect(testappService).toBeDefined();
});
describe('Test cases related to .add()', function() {
it('testappService.add should be defined', function() {
expect(testappService.add).toBeDefined();
});
});
});
与.add()
相关的测试用例✗应定义testappService.add
预定未定义的定义。
我已经为此搜索了一个解决方案,却找不到任何解决方案。我想知道如何测试这种服务。
答案 0 :(得分:0)
expect(testappService().add).toBeDefined();
describe('Test cases related to .add()', function() {
it('testappService.add should be defined', function() {
expect(testappService().add).toBeDefined();
});
});