-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainTest.js
44 lines (33 loc) · 921 Bytes
/
mainTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
describe('main', function() {
module.sharedInjector();
beforeAll(module("main", function($provide) {
$provide.value("stubMe", {
service: "stubbed",
})
}))
var answer;
var beforeAllRuns = 0;
var beforeEachRuns = 0;
beforeAll(inject(function(someService) {
beforeAllRuns += 1;
answer = someService.question();
}))
beforeEach(function() {
beforeEachRuns += 1;
})
it('it has successfully run beforeAll', function() {
expect(answer).toBe(42)
})
it('so I can make many specific assertions', function() {
expect(isNaN(answer)).toBe(false)
})
it('without re-running expensive setup', function() {
expect(beforeAllRuns).toBe(1)
})
it('allows me to stub', inject(function(stubMe) {
expect(stubMe.service).toBe("stubbed")
}))
it('allows me to use beforeEach too', function() {
expect(beforeEachRuns).toBeGreaterThan(2);
})
})