AngularJS 单元测试服务
示例
服务编号
angular.module('myModule', []).service('myService', function() {
this.doSomething= function(someNumber) {
return someNumber + 2;
}
});
考试
describe('myService', function() {var myService;
beforeEach(function() {
module('myModule');
inject(function(_myService_) {
myService = _myService_;
});
});
it('should increment `num` by 2', function() {
var result = myService.doSomething(4);
expect(result).toEqual(6);
});
});
跑!
以上是 AngularJS 单元测试服务 的全部内容, 来源链接: utcz.com/z/340699.html