@@ -1123,7 +1123,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1123
1123
*
1124
1124
* @param {string } method HTTP method.
1125
1125
* @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.
1127
1128
* @param {(Object|function(Object))= } headers HTTP headers or function that receives http header
1128
1129
* object and returns true if the headers match the current definition.
1129
1130
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
@@ -1199,7 +1200,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1199
1200
* Creates a new backend definition for POST requests. For more info see `when()`.
1200
1201
*
1201
1202
* @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.
1203
1205
* @param {(Object|function(Object))= } headers HTTP headers.
1204
1206
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
1205
1207
* request is handled.
@@ -1213,7 +1215,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1213
1215
* Creates a new backend definition for PUT requests. For more info see `when()`.
1214
1216
*
1215
1217
* @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.
1217
1220
* @param {(Object|function(Object))= } headers HTTP headers.
1218
1221
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
1219
1222
* request is handled.
@@ -1242,7 +1245,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1242
1245
*
1243
1246
* @param {string } method HTTP method.
1244
1247
* @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.
1246
1250
* @param {(Object|function(Object))= } headers HTTP headers or function that receives http header
1247
1251
* object and returns true if the headers match the current expectation.
1248
1252
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
@@ -1311,7 +1315,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1311
1315
* Creates a new request expectation for POST requests. For more info see `expect()`.
1312
1316
*
1313
1317
* @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.
1315
1320
* @param {Object= } headers HTTP headers.
1316
1321
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
1317
1322
* request is handled.
@@ -1325,7 +1330,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1325
1330
* Creates a new request expectation for PUT requests. For more info see `expect()`.
1326
1331
*
1327
1332
* @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.
1329
1335
* @param {Object= } headers HTTP headers.
1330
1336
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
1331
1337
* request is handled.
@@ -1339,7 +1345,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
1339
1345
* Creates a new request expectation for PATCH requests. For more info see `expect()`.
1340
1346
*
1341
1347
* @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.
1343
1350
* @param {Object= } headers HTTP headers.
1344
1351
* @returns {requestHandler } Returns an object with `respond` method that control how a matched
1345
1352
* request is handled.
@@ -1492,6 +1499,7 @@ function MockHttpExpectation(method, url, data, headers) {
1492
1499
this . matchData = function ( d ) {
1493
1500
if ( angular . isUndefined ( data ) ) return true ;
1494
1501
if ( data && angular . isFunction ( data . test ) ) return data . test ( d ) ;
1502
+ if ( data && angular . isFunction ( data ) ) return data ( d ) ;
1495
1503
if ( data && ! angular . isString ( data ) ) return angular . toJson ( data ) == d ;
1496
1504
return data == d ;
1497
1505
} ;
0 commit comments