Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dodgy use of stub promise in test #368

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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