Search code examples
javascriptangularjsunit-testingjasmineangularjs-ngmock

How to check if a GET call is not made in $httpBackend


$httpBackend offers methods for check if an HTTP call is made:

$httpBackend.expectGET('/auth.py');

I'm testing a service that has an internal cache and I would like to check if it works correctly. The idea is to check if the GET call is NOT made after a second request.

I'm using Karma and Jasmine.


Solution

  • This should do the trick :

    it('should be cache', function() {
    
     myCacheStuff();
     $httpBackend.flush();
     $httpBackend.verifyNoOutstandingRequest();
    })