@@ -9,21 +9,22 @@ isLoadingBarInjected = (doc) ->
9
9
10
10
describe ' loadingBarInterceptor Service' , ->
11
11
12
- $http = $httpBackend = $document = $timeout = result = loadingBar = null
12
+ $http = $httpBackend = $document = $timeout = result = loadingBar = $animate = null
13
13
response = {message : ' OK' }
14
14
endpoint = ' /service'
15
15
16
16
beforeEach ->
17
- module ' chieffancypants.loadingBar' , (cfpLoadingBarProvider ) ->
17
+ module ' ngAnimateMock ' , ' chieffancypants.loadingBar' , (cfpLoadingBarProvider ) ->
18
18
loadingBar = cfpLoadingBarProvider
19
19
return
20
20
21
21
result = null
22
- inject (_$http_ , _$httpBackend_ , _$document_ , _$timeout_ ) ->
22
+ inject (_$http_ , _$httpBackend_ , _$document_ , _$timeout_ , _$animate_ ) ->
23
23
$http = _$http_
24
24
$httpBackend = _$httpBackend_
25
25
$document = _$document_
26
26
$timeout = _$timeout_
27
+ $animate = _$animate_
27
28
28
29
beforeEach ->
29
30
this .addMatchers
@@ -53,6 +54,8 @@ describe 'loadingBarInterceptor Service', ->
53
54
expect (cfpLoadingBar .status ()).toBe 1
54
55
cfpLoadingBar .complete () # set as complete
55
56
$timeout .flush ()
57
+ $animate .triggerCallbacks ()
58
+
56
59
57
60
$http .get (endpoint, cache : cache).then (data) ->
58
61
result = data
@@ -75,6 +78,8 @@ describe 'loadingBarInterceptor Service', ->
75
78
expect (cfpLoadingBar .status ()).toBe 1
76
79
cfpLoadingBar .complete () # set as complete
77
80
$timeout .flush ()
81
+ $animate .triggerCallbacks ()
82
+
78
83
79
84
$http .get (endpoint).then (data) ->
80
85
result = data
@@ -96,6 +101,8 @@ describe 'loadingBarInterceptor Service', ->
96
101
expect (cfpLoadingBar .status ()).toBe 1
97
102
cfpLoadingBar .complete () # set as complete
98
103
$timeout .flush ()
104
+ $animate .triggerCallbacks ()
105
+
99
106
100
107
$http .get (endpoint, cache : true ).then (data) ->
101
108
result = data
@@ -115,6 +122,7 @@ describe 'loadingBarInterceptor Service', ->
115
122
$httpBackend .flush (1 )
116
123
expect (cfpLoadingBar .status ()).toBe 1
117
124
$timeout .flush ()
125
+ $animate .triggerCallbacks ()
118
126
119
127
120
128
$httpBackend .expectPOST (endpoint).respond response
@@ -340,6 +348,8 @@ describe 'loadingBarInterceptor Service', ->
340
348
expect (startedEventCalled).toBe 1 # Should still be one, as complete was never called:
341
349
cfpLoadingBar .complete ()
342
350
$timeout .flush ()
351
+ $animate .triggerCallbacks ()
352
+
343
353
344
354
cfpLoadingBar .start ()
345
355
expect (startedEventCalled).toBe 2
@@ -434,12 +444,12 @@ describe 'LoadingBar only', ->
434
444
cfpLoadingBar .start ()
435
445
$timeout .flush ()
436
446
$animate .triggerCallbacks ()
437
-
447
+
438
448
expect (isLoadingBarInjected ($document .find (cfpLoadingBar .parentSelector ))).toBe true
439
449
440
450
cfpLoadingBar .complete ()
441
451
$timeout .flush ()
442
452
$animate .triggerCallbacks ()
443
-
453
+
444
454
expect (isLoadingBarInjected ($document .find (cfpLoadingBar .parentSelector ))).toBe false
445
455
0 commit comments