ngMock.$httpBackend.whenGET()

whenGET(url, [headers], [keys]); Creates a new backend definition for GET requests. For more info see when(). Parameters Param Type Details url stringRegExpfunction(string) HTTP url or function that receives a url and returns true if the url matches the current definition. headers (optional) Objectfunction(Object) HTTP headers. keys (optional) Array Array of keys to assign to regex matches in request url described above. Returns requestHandler Returns an object with respo

ngMock.$httpBackend.whenDELETE()

whenDELETE(url, [headers], [keys]); Creates a new backend definition for DELETE requests. For more info see when(). Parameters Param Type Details url stringRegExpfunction(string) HTTP url or function that receives a url and returns true if the url matches the current definition. headers (optional) Objectfunction(Object) HTTP headers. keys (optional) Array Array of keys to assign to regex matches in request url described above. Returns requestHandler Returns an object with

ngMock.$httpBackend.when()

when(method, url, [data], [headers], [keys]); Creates a new backend definition. Parameters Param Type Details method string HTTP method. url stringRegExpfunction(string) HTTP url or function that receives a url and returns true if the url matches the current definition. data (optional) stringRegExpfunction(string) HTTP request body or function that receives data string and returns true if the data is as expected. headers (optional) Objectfunction(Object) HTTP headers or

ngMock.$httpBackend.verifyNoOutstandingRequest()

verifyNoOutstandingRequest(); Verifies that there are no outstanding requests that need to be flushed. Typically, you would call this method following each test case that asserts requests using an "afterEach" clause. afterEach($httpBackend.verifyNoOutstandingRequest);

ngMock.$httpBackend.verifyNoOutstandingExpectation()

verifyNoOutstandingExpectation(); Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception. Typically, you would call this method following each test case that asserts requests using an "afterEach" clause. afterEach($httpBackend.verifyNoOutstandingExpectation);

ngMock.$httpBackend.resetExpectations()

resetExpectations(); Resets all request expectations, but preserves all backend definitions. Typically, you would call resetExpectations during a multiple-phase test when you want to reuse the same instance of $httpBackend mock.

ngMock.$httpBackend.flush()

flush([count]); Flushes all pending requests using the trained responses. Parameters Param Type Details count (optional) number Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed. If there are no pending requests when the flush method is called an exception is thrown (as this typically a sign of programming error).

ngMock.$httpBackend.expectRoute()

expectRoute(method, url); Creates a new request expectation that compares only with the requested route. Parameters Param Type Details method string HTTP method. url string HTTP url string that supports colon param matching. Returns requestHandler Returns an object with respond method that controls how a matched request is handled. You can save this object for later use and invoke respond again in order to change how a matched request is handled. See #expect for more info.

ngMock.$httpBackend.expectPUT()

expectPUT(url, [data], [headers], [keys]); Creates a new request expectation for PUT requests. For more info see expect(). Parameters Param Type Details url stringRegExpfunction(string) HTTP url or function that receives a url and returns true if the url matches the current definition. data (optional) stringRegExpfunction(string)Object HTTP request body or function that receives data string and returns true if the data is as expected, or Object if request body is in JSON format.

ngMock.$httpBackend.expectPOST()

expectPOST(url, [data], [headers], [keys]); Creates a new request expectation for POST requests. For more info see expect(). Parameters Param Type Details url stringRegExpfunction(string) HTTP url or function that receives a url and returns true if the url matches the current definition. data (optional) stringRegExpfunction(string)Object HTTP request body or function that receives data string and returns true if the data is as expected, or Object if request body is in JSON format.