@@ -1123,7 +1123,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
11231123 *
11241124 * @param {string } method HTTP method.
11251125 * @param {string|RegExp } url HTTP url.
1126- * @param {(string|RegExp)= } data HTTP request body.
1126+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1127+ * data string and returns true if the data is as expected.
11271128 * @param {(Object|function(Object))= } headers HTTP headers or function that receives http header
11281129 * object and returns true if the headers match the current definition.
11291130 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
@@ -1199,7 +1200,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
11991200 * Creates a new backend definition for POST requests. For more info see `when()`.
12001201 *
12011202 * @param {string|RegExp } url HTTP url.
1202- * @param {(string|RegExp)= } data HTTP request body.
1203+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1204+ * data string and returns true if the data is as expected.
12031205 * @param {(Object|function(Object))= } headers HTTP headers.
12041206 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
12051207 * request is handled.
@@ -1213,7 +1215,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
12131215 * Creates a new backend definition for PUT requests. For more info see `when()`.
12141216 *
12151217 * @param {string|RegExp } url HTTP url.
1216- * @param {(string|RegExp)= } data HTTP request body.
1218+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1219+ * data string and returns true if the data is as expected.
12171220 * @param {(Object|function(Object))= } headers HTTP headers.
12181221 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
12191222 * request is handled.
@@ -1242,7 +1245,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
12421245 *
12431246 * @param {string } method HTTP method.
12441247 * @param {string|RegExp } url HTTP url.
1245- * @param {(string|RegExp)= } data HTTP request body.
1248+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1249+ * data string and returns true if the data is as expected.
12461250 * @param {(Object|function(Object))= } headers HTTP headers or function that receives http header
12471251 * object and returns true if the headers match the current expectation.
12481252 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
@@ -1311,7 +1315,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
13111315 * Creates a new request expectation for POST requests. For more info see `expect()`.
13121316 *
13131317 * @param {string|RegExp } url HTTP url.
1314- * @param {(string|RegExp)= } data HTTP request body.
1318+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1319+ * data string and returns true if the data is as expected.
13151320 * @param {Object= } headers HTTP headers.
13161321 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
13171322 * request is handled.
@@ -1325,7 +1330,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
13251330 * Creates a new request expectation for PUT requests. For more info see `expect()`.
13261331 *
13271332 * @param {string|RegExp } url HTTP url.
1328- * @param {(string|RegExp)= } data HTTP request body.
1333+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1334+ * data string and returns true if the data is as expected.
13291335 * @param {Object= } headers HTTP headers.
13301336 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
13311337 * request is handled.
@@ -1339,7 +1345,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
13391345 * Creates a new request expectation for PATCH requests. For more info see `expect()`.
13401346 *
13411347 * @param {string|RegExp } url HTTP url.
1342- * @param {(string|RegExp)= } data HTTP request body.
1348+ * @param {(string|RegExp|function(string))= } data HTTP request body or function that receives
1349+ * data string and returns true if the data is as expected.
13431350 * @param {Object= } headers HTTP headers.
13441351 * @returns {requestHandler } Returns an object with `respond` method that control how a matched
13451352 * request is handled.
@@ -1492,6 +1499,7 @@ function MockHttpExpectation(method, url, data, headers) {
14921499 this . matchData = function ( d ) {
14931500 if ( angular . isUndefined ( data ) ) return true ;
14941501 if ( data && angular . isFunction ( data . test ) ) return data . test ( d ) ;
1502+ if ( data && angular . isFunction ( data ) ) return data ( d ) ;
14951503 if ( data && ! angular . isString ( data ) ) return angular . toJson ( data ) == d ;
14961504 return data == d ;
14971505 } ;
0 commit comments