Mock fix
This commit is contained in:
@ -101,16 +101,17 @@ function mockResponses (route, targets) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
let mockedResponse = target.response
|
debug('target response: %j', target.response)
|
||||||
if (t.isFunction(target.response)) {
|
if (t.isFunction(target.response)) {
|
||||||
const pathMatches = ctx.url.match(pathRe).slice(1)
|
const pathMatches = ctx.url.match(pathRe).slice(1)
|
||||||
const ctor = target.response.bind(null, ...[ctx].concat(pathMatches))
|
target.response.apply(null, [ctx].concat(pathMatches))
|
||||||
mockedResponse = new ctor()
|
} else {
|
||||||
|
Object.assign(ctx.response, target.response)
|
||||||
}
|
}
|
||||||
debug('target response: %j', mockedResponse)
|
|
||||||
Object.assign(ctx.response, mockedResponse)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return next()
|
||||||
}
|
}
|
||||||
return next()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user