add async mock capability.. fixes #26

This commit is contained in:
Lloyd Brookes
2015-12-13 13:02:48 +00:00
parent 7ca0da3d85
commit 5350186614
4 changed files with 47 additions and 2 deletions

View File

@ -101,10 +101,9 @@ function mockResponses (route, targets) {
}
if (target) {
// debug('target response: %s', target.response)
if (t.isFunction(target.response)) {
const pathMatches = ctx.path.match(pathRe).slice(1)
target.response.apply(null, [ctx].concat(pathMatches))
return target.response.apply(null, [ctx].concat(pathMatches))
} else if (t.isPlainObject(target.response)) {
Object.assign(ctx.response, target.response)
} else {