Skip to content

Commit 2788de7

Browse files
committed
Add test for stateful interceptor
1 parent 9991b0a commit 2788de7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/interceptors.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ describe('interceptors', function(){
4343
}
4444
});
4545

46+
$httpProvider.interceptors.push(function(){
47+
var count = 0;
48+
return {
49+
response: function(response){
50+
count++;
51+
response.headers['stateful-anonymous-response-count'] = count;
52+
53+
return response;
54+
}
55+
}
56+
});
57+
4658
$httpProvider.interceptors.push(['$q', function($q){
4759
return {
4860
request: function(config){
@@ -115,6 +127,21 @@ describe('interceptors', function(){
115127
});
116128
});
117129

130+
it('allows for intercepts through stateful anonymous factory', function(done){
131+
http({
132+
method: 'GET',
133+
url: 'test-url.com/anonymous-intercept'
134+
}).then(function(){
135+
return http({
136+
method: 'GET',
137+
url: 'test-url.com/anonymous-intercept'
138+
});
139+
}).then(function(response){
140+
expect(response.headers['stateful-anonymous-response-count']).toBeGreaterThan(1);
141+
done();
142+
});
143+
});
144+
118145
it('allows for intercepts that return a promise from a request', function(done){
119146
http({
120147
method: 'POST',

0 commit comments

Comments
 (0)