Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 78a404d

Browse files
robinjNarretz
authored andcommitted
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
1 parent f1bb836 commit 78a404d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/ngMock/angular-mocks.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,12 +1416,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
14161416
* order to change how a matched request is handled.
14171417
*
14181418
* - respond –
1419-
* `{function([status,] data[, headers, statusText])
1420-
* | function(function(method, url, data, headers, params)}`
1419+
* ```js
1420+
* {function([status,] data[, headers, statusText])
1421+
* | function(function(method, url, data, headers, params)}
1422+
* ```
14211423
* – The respond method takes a set of static data to be returned or a function that can
1422-
* return an array containing response status (number), response data (string), response
1423-
* headers (Object), and the text for the status (string). The respond method returns the
1424-
* `requestHandler` object for possible overrides.
1424+
* return an array containing response status (number), response data (Array|Object|string),
1425+
* response headers (Object), and the text for the status (string). The respond method returns
1426+
* the `requestHandler` object for possible overrides.
14251427
*/
14261428
$httpBackend.when = function(method, url, data, headers, keys) {
14271429
var definition = new MockHttpExpectation(method, url, data, headers, keys),
@@ -1606,12 +1608,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
16061608
* order to change how a matched request is handled.
16071609
*
16081610
* - respond –
1609-
* `{function([status,] data[, headers, statusText])
1610-
* | function(function(method, url, data, headers, params)}`
1611+
* ```
1612+
* { function([status,] data[, headers, statusText])
1613+
* | function(function(method, url, data, headers, params)}
1614+
* ```
16111615
* – The respond method takes a set of static data to be returned or a function that can
1612-
* return an array containing response status (number), response data (string), response
1613-
* headers (Object), and the text for the status (string). The respond method returns the
1614-
* `requestHandler` object for possible overrides.
1616+
* return an array containing response status (number), response data (Array|Object|string),
1617+
* response headers (Object), and the text for the status (string). The respond method returns
1618+
* the `requestHandler` object for possible overrides.
16151619
*/
16161620
$httpBackend.expect = function(method, url, data, headers, keys) {
16171621
var expectation = new MockHttpExpectation(method, url, data, headers, keys),
@@ -2326,11 +2330,13 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
23262330
* `respond` or `passThrough` again in order to change how a matched request is handled.
23272331
*
23282332
* - respond –
2329-
* `{function([status,] data[, headers, statusText])
2330-
* | function(function(method, url, data, headers, params)}`
2333+
* ```
2334+
* { function([status,] data[, headers, statusText])
2335+
* | function(function(method, url, data, headers, params)}
2336+
* ```
23312337
* – The respond method takes a set of static data to be returned or a function that can return
2332-
* an array containing response status (number), response data (string), response headers
2333-
* (Object), and the text for the status (string).
2338+
* an array containing response status (number), response data (Array|Object|string), response
2339+
* headers (Object), and the text for the status (string).
23342340
* - passThrough – `{function()}` – Any request matching a backend definition with
23352341
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
23362342
* to the server.)

0 commit comments

Comments
 (0)