mock response routes no longer pay attention to query strings
This commit is contained in:
@ -78,11 +78,11 @@ function mime (mimeTypes) {
|
||||
|
||||
function mockResponses (route, targets) {
|
||||
targets = arrayify(targets)
|
||||
debug('mock route: %s, targets: %j', route, targets);
|
||||
debug('mock route: %s, targets: %s', route, targets.length);
|
||||
const pathRe = pathToRegexp(route)
|
||||
|
||||
return function mockResponse (ctx, next) {
|
||||
if (pathRe.test(ctx.url)) {
|
||||
if (pathRe.test(ctx.path)) {
|
||||
const testValue = require('test-value')
|
||||
|
||||
/* find a mock with compatible method and accepts */
|
||||
@ -101,9 +101,9 @@ function mockResponses (route, targets) {
|
||||
}
|
||||
|
||||
if (target) {
|
||||
debug('target response: %s', target.response)
|
||||
// debug('target response: %s', target.response)
|
||||
if (t.isFunction(target.response)) {
|
||||
const pathMatches = ctx.url.match(pathRe).slice(1)
|
||||
const pathMatches = ctx.path.match(pathRe).slice(1)
|
||||
target.response.apply(null, [ctx].concat(pathMatches))
|
||||
} else if (t.isPlainObject(target.response)) {
|
||||
Object.assign(ctx.response, target.response)
|
||||
|
Reference in New Issue
Block a user