mappersmith
Advanced tools
Comparing version 2.32.0 to 2.32.1
@@ -16,3 +16,3 @@ "use strict"; | ||
/* global VERSION */ | ||
var version = "2.32.0"; | ||
var version = "2.32.1"; | ||
exports.version = version; | ||
@@ -19,0 +19,0 @@ var configs = { |
@@ -163,7 +163,11 @@ "use strict"; | ||
if (!hasParamMatchers) { | ||
return finalRequest.url(); | ||
} | ||
var urlMatcher = function urlMatcher(requestUrl, requestParams) { | ||
var expandedParams = _this2.expandParams(params, requestParams); | ||
var additionalParams = _this2.evaluateParamMatchers(params, requestParams); | ||
var testRequest = finalRequest.enhance({ | ||
params: expandedParams | ||
params: additionalParams | ||
}); | ||
@@ -173,3 +177,3 @@ return testRequest.url() === requestUrl; | ||
return hasParamMatchers ? urlMatcher : finalRequest.url(); | ||
return urlMatcher; | ||
}, | ||
@@ -199,10 +203,17 @@ | ||
*/ | ||
expandParams: function expandParams(mockParams, requestParams) { | ||
evaluateParamMatchers: function evaluateParamMatchers(mockParams, requestParams) { | ||
return Object.keys(mockParams).reduce(function (obj, key) { | ||
var value = requestParams[key]; | ||
var matcher = mockParams[key]; | ||
if (typeof mockParams[key] === 'function') { | ||
obj[key] = mockParams[key](value) ? value : VALUE_NOT_MATCHED; | ||
if (typeof matcher !== 'function') { | ||
return obj; | ||
} | ||
var value = requestParams[key]; // Only evaluate if key was provided in request params. | ||
// Otherwise we always consider it not to match. | ||
if (key in requestParams && matcher(value)) { | ||
obj[key] = value; | ||
} else { | ||
obj[key] = value; | ||
obj[key] = VALUE_NOT_MATCHED; | ||
} | ||
@@ -209,0 +220,0 @@ |
{ | ||
"name": "mappersmith", | ||
"version": "2.32.0", | ||
"version": "2.32.1", | ||
"description": "It is a lightweight rest client for node.js and the browser", | ||
@@ -5,0 +5,0 @@ "author": "Tulio Ornelas <ornelas.tulio@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150332
2841