Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
test($httpBackend): check if unexpected request fail on verify no out…
Browse files Browse the repository at this point in the history
…standing request
  • Loading branch information
marcin-wosinek committed Aug 6, 2017
1 parent 56ac2a7 commit c1ad9ac
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ describe('ngMock', function() {

describe('ngMockE2E', function() {
describe('$httpBackend', function() {
var hb, realHttpBackend, realHttpBackendBrowser, callback;
var hb, realHttpBackend, realHttpBackendBrowser, $http, callback;

beforeEach(function() {
callback = jasmine.createSpy('callback');
Expand All @@ -2442,10 +2442,29 @@ describe('ngMockE2E', function() {
module('ngMockE2E');
inject(function($injector) {
hb = $injector.get('$httpBackend');
$http = $injector.get('$http');
});
});


it('should throw error when unexpected request - without error callback', function() {
expect(function() {
$http.get('/some').then(noop);

hb.verifyNoOutstandingRequest();
}).toThrowError('Unexpected request: GET /some\nNo more request expected');
});


it('should throw error when unexpected request - with error callback', function() {
expect(function() {
$http.get('/some').then(noop, noop);

hb.verifyNoOutstandingRequest();
}).toThrowError('Unexpected request: GET /some\nNo more request expected');
});


describe('passThrough()', function() {
it('should delegate requests to the real backend when passThrough is invoked', function() {
var eventHandlers = {progress: angular.noop};
Expand Down

0 comments on commit c1ad9ac

Please sign in to comment.