Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

Commit 5cdd53d

Browse files
committed
add service.get test
1 parent d558cdf commit 5cdd53d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test/unit/services/example_spec.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
describe('Unit: ExampleService', function() {
66

7-
var service;
7+
var http, service;
88

99
beforeEach(function() {
1010
// instantiate the app module
1111
angular.mock.module('app');
1212

1313
// mock the service
14-
angular.mock.inject(function(ExampleService) {
14+
angular.mock.inject(function($httpBackend, ExampleService) {
15+
http = $httpBackend;
1516
service = ExampleService;
1617
});
1718
});
@@ -20,4 +21,15 @@ describe('Unit: ExampleService', function() {
2021
expect(service).toBeDefined();
2122
});
2223

23-
});
24+
it('should retrieve data', function(done) {
25+
http.expect('GET', 'apiPath').respond(201, {data: 1234});
26+
27+
service.get().then(function(result) {
28+
expect(result).toEqual({data: 1234});
29+
}, function(error) {
30+
expect(error).toBeUndefined();
31+
}).then(done);
32+
33+
http.flush();
34+
});
35+
});

0 commit comments

Comments
 (0)