mock response routes no longer pay attention to query strings

This commit is contained in:
Lloyd Brookes
2015-11-27 22:48:53 +00:00
parent 383d48473c
commit 0c78138fd9
5 changed files with 16 additions and 16 deletions

View File

@ -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)