Skip to content

Commit

Permalink
fix dodgy use of stub promise in test
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Sep 24, 2018
1 parent 4715e34 commit 65c97cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/lib/fetch-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const resolve = async (response, url, opts) => {
if (typeof response === 'function') {
response = response(url, opts);
} else {
// Strange .then is to cope with non ES Promises... god knows why it works
response = await response.then(it => it);
response = await response;
}
}
return response;
Expand Down
6 changes: 4 additions & 2 deletions test/specs/custom-implementations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ module.exports = fetchMock => {

it('should allow non-native Promises as responses', async () => {
fm.config.Promise = BluebirdPromise;
const stub = sinon.spy(() =>
BluebirdPromise.resolve(new fm.config.Response('', { status: 203 }))
const stub = sinon.spy(fn =>
fn(
BluebirdPromise.resolve(new fm.config.Response('', { status: 203 }))
)
);
fm.mock(/.*/, {
then: stub
Expand Down

0 comments on commit 65c97cb

Please sign in to comment.