Skip to content

Commit a76b43f

Browse files
fix tests to work with newer ngAnimateMock
1 parent 7a62d02 commit a76b43f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

test/loading-bar-interceptor.coffee

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ isLoadingBarInjected = (doc) ->
99

1010
describe 'loadingBarInterceptor Service', ->
1111

12-
$http = $httpBackend = $document = $timeout = result = loadingBar = null
12+
$http = $httpBackend = $document = $timeout = result = loadingBar = $animate = null
1313
response = {message:'OK'}
1414
endpoint = '/service'
1515

1616
beforeEach ->
17-
module 'chieffancypants.loadingBar', (cfpLoadingBarProvider) ->
17+
module 'ngAnimateMock', 'chieffancypants.loadingBar', (cfpLoadingBarProvider) ->
1818
loadingBar = cfpLoadingBarProvider
1919
return
2020

2121
result = null
22-
inject (_$http_, _$httpBackend_, _$document_, _$timeout_) ->
22+
inject (_$http_, _$httpBackend_, _$document_, _$timeout_, _$animate_) ->
2323
$http = _$http_
2424
$httpBackend = _$httpBackend_
2525
$document = _$document_
2626
$timeout = _$timeout_
27+
$animate = _$animate_
2728

2829
beforeEach ->
2930
this.addMatchers
@@ -53,6 +54,8 @@ describe 'loadingBarInterceptor Service', ->
5354
expect(cfpLoadingBar.status()).toBe 1
5455
cfpLoadingBar.complete() # set as complete
5556
$timeout.flush()
57+
$animate.triggerCallbacks()
58+
5659

5760
$http.get(endpoint, cache: cache).then (data) ->
5861
result = data
@@ -75,6 +78,8 @@ describe 'loadingBarInterceptor Service', ->
7578
expect(cfpLoadingBar.status()).toBe 1
7679
cfpLoadingBar.complete() # set as complete
7780
$timeout.flush()
81+
$animate.triggerCallbacks()
82+
7883

7984
$http.get(endpoint).then (data) ->
8085
result = data
@@ -96,6 +101,8 @@ describe 'loadingBarInterceptor Service', ->
96101
expect(cfpLoadingBar.status()).toBe 1
97102
cfpLoadingBar.complete() # set as complete
98103
$timeout.flush()
104+
$animate.triggerCallbacks()
105+
99106

100107
$http.get(endpoint, cache: true).then (data) ->
101108
result = data
@@ -115,6 +122,7 @@ describe 'loadingBarInterceptor Service', ->
115122
$httpBackend.flush(1)
116123
expect(cfpLoadingBar.status()).toBe 1
117124
$timeout.flush()
125+
$animate.triggerCallbacks()
118126

119127

120128
$httpBackend.expectPOST(endpoint).respond response
@@ -340,6 +348,8 @@ describe 'loadingBarInterceptor Service', ->
340348
expect(startedEventCalled).toBe 1 # Should still be one, as complete was never called:
341349
cfpLoadingBar.complete()
342350
$timeout.flush()
351+
$animate.triggerCallbacks()
352+
343353

344354
cfpLoadingBar.start()
345355
expect(startedEventCalled).toBe 2
@@ -434,12 +444,12 @@ describe 'LoadingBar only', ->
434444
cfpLoadingBar.start()
435445
$timeout.flush()
436446
$animate.triggerCallbacks()
437-
447+
438448
expect(isLoadingBarInjected($document.find(cfpLoadingBar.parentSelector))).toBe true
439449

440450
cfpLoadingBar.complete()
441451
$timeout.flush()
442452
$animate.triggerCallbacks()
443-
453+
444454
expect(isLoadingBarInjected($document.find(cfpLoadingBar.parentSelector))).toBe false
445455

0 commit comments

Comments
 (0)