【发布时间】:2014-02-03 18:19:43
【问题描述】:
我的测试是:
'use strict';
(function() {
describe('Service: Summary', function () {
var $httpBackend;
// load the service's module
beforeEach(module('mean'));
var SummaryService;
beforeEach(inject(function($injector, _SummaryService_) {
SummaryService = _SummaryService_;
$httpBackend = $injector.get('$httpBackend');
}));
// instantiate service
it('should do something', function () {
expect(!!SummaryService).toBe(true);
});
it('should get a summary', function () {
$httpBackend.expectGET('/api/ABC').respond(200);
SummaryService.get();
});
});
})();
我的服务是:
'use strict';
angular.module('mean')
.service('SummaryService', ['$http', function SummaryService($http) {
var summary = this;
summary.get = function () {
return $http.get('/api/summary');
};
}]);
如您所见,它应该转到/api/summary 而不是/api/ABC,但测试仍然通过。我做错了什么?
【问题讨论】:
标签: angularjs unit-testing karma-runner