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

Commit fd0b1eb

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 038d990 commit fd0b1eb

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
@@ -1417,12 +1417,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
14171417
* order to change how a matched request is handled.
14181418
*
14191419
* - respond –
1420-
* `{function([status,] data[, headers, statusText])
1421-
* | function(function(method, url, data, headers, params)}`
1420+
* ```js
1421+
* {function([status,] data[, headers, statusText])
1422+
* | function(function(method, url, data, headers, params)}
1423+
* ```
14221424
* – The respond method takes a set of static data to be returned or a function that can
1423-
* return an array containing response status (number), response data (string), response
1424-
* headers (Object), and the text for the status (string). The respond method returns the
1425-
* `requestHandler` object for possible overrides.
1425+
* return an array containing response status (number), response data (Array|Object|string),
1426+
* response headers (Object), and the text for the status (string). The respond method returns
1427+
* the `requestHandler` object for possible overrides.
14261428
*/
14271429
$httpBackend.when = function(method, url, data, headers, keys) {
14281430
var definition = new MockHttpExpectation(method, url, data, headers, keys),
@@ -1607,12 +1609,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
16071609
* order to change how a matched request is handled.
16081610
*
16091611
* - respond –
1610-
* `{function([status,] data[, headers, statusText])
1611-
* | function(function(method, url, data, headers, params)}`
1612+
* ```
1613+
* { function([status,] data[, headers, statusText])
1614+
* | function(function(method, url, data, headers, params)}
1615+
* ```
16121616
* – The respond method takes a set of static data to be returned or a function that can
1613-
* return an array containing response status (number), response data (string), response
1614-
* headers (Object), and the text for the status (string). The respond method returns the
1615-
* `requestHandler` object for possible overrides.
1617+
* return an array containing response status (number), response data (Array|Object|string),
1618+
* response headers (Object), and the text for the status (string). The respond method returns
1619+
* the `requestHandler` object for possible overrides.
16161620
*/
16171621
$httpBackend.expect = function(method, url, data, headers, keys) {
16181622
var expectation = new MockHttpExpectation(method, url, data, headers, keys),
@@ -2327,11 +2331,13 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
23272331
* `respond` or `passThrough` again in order to change how a matched request is handled.
23282332
*
23292333
* - respond –
2330-
* `{function([status,] data[, headers, statusText])
2331-
* | function(function(method, url, data, headers, params)}`
2334+
* ```
2335+
* { function([status,] data[, headers, statusText])
2336+
* | function(function(method, url, data, headers, params)}
2337+
* ```
23322338
* – The respond method takes a set of static data to be returned or a function that can return
2333-
* an array containing response status (number), response data (string), response headers
2334-
* (Object), and the text for the status (string).
2339+
* an array containing response status (number), response data (Array|Object|string), response
2340+
* headers (Object), and the text for the status (string).
23352341
* - passThrough – `{function()}` – Any request matching a backend definition with
23362342
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
23372343
* to the server.)

0 commit comments

Comments
 (0)