docs($httpBackend): update response data types
Updated docs to reflect that response data can either be an array, object _or_ a string Technically, response data can be anything that can be handled by angular.copy, but since string and JSON data is most commonly mocked, the main types are sufficient. Closes #14346
This commit is contained in:
committed by
Martin Staffa
parent
038d990bc1
commit
fd0b1ebfc7
Vendored
+20
-14
@@ -1417,12 +1417,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
||||
* order to change how a matched request is handled.
|
||||
*
|
||||
* - respond –
|
||||
* `{function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}`
|
||||
* ```js
|
||||
* {function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}
|
||||
* ```
|
||||
* – The respond method takes a set of static data to be returned or a function that can
|
||||
* return an array containing response status (number), response data (string), response
|
||||
* headers (Object), and the text for the status (string). The respond method returns the
|
||||
* `requestHandler` object for possible overrides.
|
||||
* return an array containing response status (number), response data (Array|Object|string),
|
||||
* response headers (Object), and the text for the status (string). The respond method returns
|
||||
* the `requestHandler` object for possible overrides.
|
||||
*/
|
||||
$httpBackend.when = function(method, url, data, headers, keys) {
|
||||
var definition = new MockHttpExpectation(method, url, data, headers, keys),
|
||||
@@ -1607,12 +1609,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
||||
* order to change how a matched request is handled.
|
||||
*
|
||||
* - respond –
|
||||
* `{function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}`
|
||||
* ```
|
||||
* { function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}
|
||||
* ```
|
||||
* – The respond method takes a set of static data to be returned or a function that can
|
||||
* return an array containing response status (number), response data (string), response
|
||||
* headers (Object), and the text for the status (string). The respond method returns the
|
||||
* `requestHandler` object for possible overrides.
|
||||
* return an array containing response status (number), response data (Array|Object|string),
|
||||
* response headers (Object), and the text for the status (string). The respond method returns
|
||||
* the `requestHandler` object for possible overrides.
|
||||
*/
|
||||
$httpBackend.expect = function(method, url, data, headers, keys) {
|
||||
var expectation = new MockHttpExpectation(method, url, data, headers, keys),
|
||||
@@ -2327,11 +2331,13 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* `respond` or `passThrough` again in order to change how a matched request is handled.
|
||||
*
|
||||
* - respond –
|
||||
* `{function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}`
|
||||
* ```
|
||||
* { function([status,] data[, headers, statusText])
|
||||
* | function(function(method, url, data, headers, params)}
|
||||
* ```
|
||||
* – The respond method takes a set of static data to be returned or a function that can return
|
||||
* an array containing response status (number), response data (string), response headers
|
||||
* (Object), and the text for the status (string).
|
||||
* an array containing response status (number), response data (Array|Object|string), response
|
||||
* headers (Object), and the text for the status (string).
|
||||
* - passThrough – `{function()}` – Any request matching a backend definition with
|
||||
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
|
||||
* to the server.)
|
||||
|
||||
Reference in New Issue
Block a user