$httpBackend.verifyNoOutstandingRequest(); does not raise error

49 views
Skip to first unread message

A G

unread,
Aug 8, 2013, 5:19:30 AM8/8/13
to ang...@googlegroups.com
Hi,

My test setups a http request but I do not execute $httpBackend.flush(). Here is the test:
describe("Unit: Testing Services", function() {
beforeEach(angular.mock.module('EmsWeb.Services'));
describe("Unit: DalService", function () {
var $httpBackend, dalService, appModel;
beforeEach(inject(function ($q, _$httpBackend_, AppModel, DalService) {
dalService = DalService;
appModel = AppModel;
$httpBackend = _$httpBackend_;
$httpBackend.when('POST', '../api/ModuleApi/GetModules').respond({ userId: 'userX', 'A-Token': 'xxx' });
appModel.context.company = { code: 'LPL' };
}));

describe("canceling request should fail", function () {

it('checks request should be canceled ', function () {
// $httpBackend.expectPOST('../api/ModuleApi/GetModules');
var returnedData;
var callBackFn = function (data) {
returnedData = data;
};
dalService.getModules('senderIdentifier', appModel.context, callBackFn, callBackFn);
});

});
afterEach(function () {
$httpBackend.verifyNoOutstandingRequest();
});
});

I expected "$httpBackend.verifyNoOutstandingRequest();" to raise an error hence there was no call to $httpBackend.flush().
I also tried to add "$httpBackend.expectPOST('../api/ModuleApi/GetModules');" but it did not make a difference.
What am I missing?

Thank you,
Alexander
Reply all
Reply to author
Forward
0 new messages