Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit ecc0eff

Browse files
refactor(services): cover the dummyService
1 parent d8cd15c commit ecc0eff

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

‎services/services.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
SampleService.$inject = ['$http', '$q', 'dummyService'];
6060

6161

62-
63-
6462
function DummyService($q) {
6563
var service = {
6664
someMethod: someMethod,
@@ -83,5 +81,4 @@
8381
}
8482

8583
DummyService.$inject = ['$q'];
86-
8784
}());

‎services/services.spec.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,32 @@ describe('SampleService', function() {
105105
});
106106
});
107107
});
108+
109+
describe('DummyService', function() {
110+
var service,
111+
$rootScope;
112+
113+
beforeEach(module('myApp'));
114+
115+
beforeEach(inject(function(_$rootScope_, _dummyService_) {
116+
$rootScope = _$rootScope_;
117+
service = _dummyService_;
118+
}));
119+
120+
describe('#someMethod', function() {
121+
it('should return `bla`', function() {
122+
expect(service.someMethod()).toBe('bla');
123+
});
124+
});
125+
126+
describe('#anotherMethod', function() {
127+
it('should return `[1,2,3]` in a promise', function() {
128+
var resultSpy = jasmine.createSpy('resultSpy');
129+
130+
service.anotherMethod().then(resultSpy);
131+
$rootScope.$apply();
132+
133+
expect(resultSpy).toHaveBeenCalledWith([1,2,3]);
134+
});
135+
});
136+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /