Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3bbe17a

Browse files
committedSep 5, 2017
test($httpBackend): check if unexpected request fail on verify no outstanding request
1 parent ecc09a4 commit 3bbe17a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎test/ngMock/angular-mocksSpec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ describe('ngMock', function() {
24292429

24302430
describe('ngMockE2E', function() {
24312431
describe('$httpBackend', function() {
2432-
var hb, realHttpBackend, realHttpBackendBrowser, callback;
2432+
var hb, realHttpBackend, realHttpBackendBrowser, $http, callback;
24332433

24342434
beforeEach(function() {
24352435
callback = jasmine.createSpy('callback');
@@ -2442,10 +2442,29 @@ describe('ngMockE2E', function() {
24422442
module('ngMockE2E');
24432443
inject(function($injector) {
24442444
hb = $injector.get('$httpBackend');
2445+
$http = $injector.get('$http');
24452446
});
24462447
});
24472448

24482449

2450+
it('should throw error when unexpected request - without error callback', function() {
2451+
expect(function() {
2452+
$http.get('/some').then(noop);
2453+
2454+
hb.verifyNoOutstandingRequest();
2455+
}).toThrowError('Unexpected request: GET /some\nNo more request expected');
2456+
});
2457+
2458+
2459+
it('should throw error when unexpected request - with error callback', function() {
2460+
expect(function() {
2461+
$http.get('/some').then(noop, noop);
2462+
2463+
hb.verifyNoOutstandingRequest();
2464+
}).toThrowError('Unexpected request: GET /some\nNo more request expected');
2465+
});
2466+
2467+
24492468
describe('passThrough()', function() {
24502469
it('should delegate requests to the real backend when passThrough is invoked', function() {
24512470
var eventHandlers = {progress: angular.noop};

0 commit comments

Comments
 (0)
This repository has been archived.