Skip to content

Commit

Permalink
Add test for stateful interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
xemle committed Aug 18, 2017
1 parent 9991b0a commit 2788de7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/interceptors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ describe('interceptors', function(){
}
});

$httpProvider.interceptors.push(function(){
var count = 0;
return {
response: function(response){
count++;
response.headers['stateful-anonymous-response-count'] = count;

return response;
}
}
});

$httpProvider.interceptors.push(['$q', function($q){
return {
request: function(config){
Expand Down Expand Up @@ -115,6 +127,21 @@ describe('interceptors', function(){
});
});

it('allows for intercepts through stateful anonymous factory', function(done){
http({
method: 'GET',
url: 'test-url.com/anonymous-intercept'
}).then(function(){
return http({
method: 'GET',
url: 'test-url.com/anonymous-intercept'
});
}).then(function(response){
expect(response.headers['stateful-anonymous-response-count']).toBeGreaterThan(1);
done();
});
});

it('allows for intercepts that return a promise from a request', function(done){
http({
method: 'POST',
Expand Down

0 comments on commit 2788de7

Please sign in to comment.