Skip to content

Commit

Permalink
Fixing rejection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m4n3z40 committed Jan 15, 2018
1 parent 85fad97 commit 5ae2641
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/jest-mock/src/__tests__/jest_mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ describe('moduleMocker', () => {

expect(promise).toBeInstanceOf(Promise);

return promise.catch(rejection => expect(rejection).toBe(err));
return promise
.then(() => Promise.reject(new Error('did not reject')))
.catch(rejection => expect(rejection).toBe(err));
});

it('supports mocking rejectable async functions only once', () => {
Expand All @@ -432,10 +434,12 @@ describe('moduleMocker', () => {
fn.mockRejectedValue(defaultErr);
fn.mockRejectedValueOnce(err);

const promise1 = fn().catch(rejection => expect(rejection).toBe(err));
const promise2 = fn().catch(rejection =>
expect(rejection).toBe(defaultErr),
);
const promise1 = fn()
.then(() => Promise.reject(new Error('did not reject')))
.catch(rejection => expect(rejection).toBe(err));
const promise2 = fn()
.then(() => Promise.reject(new Error('did not reject')))
.catch(rejection => expect(rejection).toBe(defaultErr));

return Promise.all([promise1, promise2]);
});
Expand Down

0 comments on commit 5ae2641

Please sign in to comment.