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

Commit a7de87d

Browse files
thorn0gkalpak
authored andcommitted
docs($httpBackend): headers param of expect* can be function
Closes #16588
1 parent 1bb9aa0 commit a7de87d

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

src/ngMock/angular-mocks.js

+33-20
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
15581558
*
15591559
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
15601560
* and returns true if the url matches the current definition.
1561-
* @param {(Object|function(Object))=} headers HTTP headers.
1561+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1562+
* object and returns true if the headers match the current definition.
15621563
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
15631564
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
15641565
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1573,7 +1574,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
15731574
*
15741575
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
15751576
* and returns true if the url matches the current definition.
1576-
* @param {(Object|function(Object))=} headers HTTP headers.
1577+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1578+
* object and returns true if the headers match the current definition.
15771579
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
15781580
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
15791581
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1588,7 +1590,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
15881590
*
15891591
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
15901592
* and returns true if the url matches the current definition.
1591-
* @param {(Object|function(Object))=} headers HTTP headers.
1593+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1594+
* object and returns true if the headers match the current definition.
15921595
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
15931596
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
15941597
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1605,7 +1608,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
16051608
* and returns true if the url matches the current definition.
16061609
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
16071610
* data string and returns true if the data is as expected.
1608-
* @param {(Object|function(Object))=} headers HTTP headers.
1611+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1612+
* object and returns true if the headers match the current definition.
16091613
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
16101614
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
16111615
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1622,7 +1626,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
16221626
* and returns true if the url matches the current definition.
16231627
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
16241628
* data string and returns true if the data is as expected.
1625-
* @param {(Object|function(Object))=} headers HTTP headers.
1629+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1630+
* object and returns true if the headers match the current definition.
16261631
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
16271632
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
16281633
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1654,7 +1659,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
16541659
* @param {string} url HTTP url string that supports colon param matching.
16551660
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
16561661
* request is handled. You can save this object for later use and invoke `respond` again in
1657-
* order to change how a matched request is handled. See #when for more info.
1662+
* order to change how a matched request is handled.
1663+
* See {@link ngMock.$httpBackend#when `when`} for more info.
16581664
*/
16591665
$httpBackend.whenRoute = function(method, url) {
16601666
var pathObj = parseRoute(url);
@@ -1743,8 +1749,9 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
17431749
* Creates a new request expectation for GET requests. For more info see `expect()`.
17441750
*
17451751
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1746-
* and returns true if the url matches the current definition.
1747-
* @param {Object=} headers HTTP headers.
1752+
* and returns true if the url matches the current expectation.
1753+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1754+
* object and returns true if the headers match the current expectation.
17481755
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
17491756
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
17501757
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1758,8 +1765,9 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
17581765
* Creates a new request expectation for HEAD requests. For more info see `expect()`.
17591766
*
17601767
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1761-
* and returns true if the url matches the current definition.
1762-
* @param {Object=} headers HTTP headers.
1768+
* and returns true if the url matches the current expectation.
1769+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1770+
* object and returns true if the headers match the current expectation.
17631771
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
17641772
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
17651773
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1773,8 +1781,9 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
17731781
* Creates a new request expectation for DELETE requests. For more info see `expect()`.
17741782
*
17751783
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1776-
* and returns true if the url matches the current definition.
1777-
* @param {Object=} headers HTTP headers.
1784+
* and returns true if the url matches the current expectation.
1785+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1786+
* object and returns true if the headers match the current expectation.
17781787
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
17791788
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
17801789
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1788,11 +1797,12 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
17881797
* Creates a new request expectation for POST requests. For more info see `expect()`.
17891798
*
17901799
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1791-
* and returns true if the url matches the current definition.
1800+
* and returns true if the url matches the current expectation.
17921801
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
17931802
* receives data string and returns true if the data is as expected, or Object if request body
17941803
* is in JSON format.
1795-
* @param {Object=} headers HTTP headers.
1804+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1805+
* object and returns true if the headers match the current expectation.
17961806
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
17971807
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
17981808
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1806,11 +1816,12 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
18061816
* Creates a new request expectation for PUT requests. For more info see `expect()`.
18071817
*
18081818
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1809-
* and returns true if the url matches the current definition.
1819+
* and returns true if the url matches the current expectation.
18101820
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
18111821
* receives data string and returns true if the data is as expected, or Object if request body
18121822
* is in JSON format.
1813-
* @param {Object=} headers HTTP headers.
1823+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1824+
* object and returns true if the headers match the current expectation.
18141825
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
18151826
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
18161827
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1824,11 +1835,12 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
18241835
* Creates a new request expectation for PATCH requests. For more info see `expect()`.
18251836
*
18261837
* @param {string|RegExp|function(string)=} url HTTP url or function that receives a url
1827-
* and returns true if the url matches the current definition.
1838+
* and returns true if the url matches the current expectation.
18281839
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
18291840
* receives data string and returns true if the data is as expected, or Object if request body
18301841
* is in JSON format.
1831-
* @param {Object=} headers HTTP headers.
1842+
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
1843+
* object and returns true if the headers match the current expectation.
18321844
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
18331845
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
18341846
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1842,7 +1854,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
18421854
* Creates a new request expectation for JSONP requests. For more info see `expect()`.
18431855
*
18441856
* @param {string|RegExp|function(string)=} url HTTP url or function that receives an url
1845-
* and returns true if the url matches the current definition.
1857+
* and returns true if the url matches the current expectation.
18461858
* @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
18471859
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
18481860
* request is handled. You can save this object for later use and invoke `respond` again in
@@ -1860,7 +1872,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
18601872
* @param {string} url HTTP url string that supports colon param matching.
18611873
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
18621874
* request is handled. You can save this object for later use and invoke `respond` again in
1863-
* order to change how a matched request is handled. See #expect for more info.
1875+
* order to change how a matched request is handled.
1876+
* See {@link ngMock.$httpBackend#expect `expect`} for more info.
18641877
*/
18651878
$httpBackend.expectRoute = function(method, url) {
18661879
var pathObj = parseRoute(url);

0 commit comments

Comments
 (0)