Skip to content

Commit

Permalink
mapAsyncIterator-test: replace 'invariant' with expect chains (#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jun 30, 2020
1 parent 11505d7 commit 5aba9c9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/subscription/__tests__/mapAsyncIterator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import invariant from '../../jsutils/invariant';

import mapAsyncIterator from '../mapAsyncIterator';

describe('mapAsyncIterator', () => {
Expand Down Expand Up @@ -271,8 +269,9 @@ describe('mapAsyncIterator', () => {
caughtError = e;
}

invariant(caughtError != null);
expect(caughtError.message).to.equal('Goodbye');
expect(caughtError)
.to.be.an.instanceOf(Error)
.with.property('message', 'Goodbye');
});

it('maps over thrown errors if second callback provided', async () => {
Expand All @@ -293,8 +292,9 @@ describe('mapAsyncIterator', () => {
});

const result = await doubles.next();
invariant(result.value instanceof Error);
expect(result.value.message).to.equal('Goodbye');
expect(result.value)
.to.be.an.instanceOf(Error)
.with.property('message', 'Goodbye');
expect(result.done).to.equal(false);

expect(await doubles.next()).to.deep.equal({
Expand Down Expand Up @@ -330,8 +330,9 @@ describe('mapAsyncIterator', () => {
expectedError = error;
}

invariant(expectedError instanceof Error);
expect(expectedError.message).to.equal('Cannot count to 2');
expect(expectedError)
.to.be.an.instanceOf(Error)
.with.property('message', 'Cannot count to 2');

expect(await throwOver1.next()).to.deep.equal({
value: undefined,
Expand Down Expand Up @@ -375,8 +376,9 @@ describe('mapAsyncIterator', () => {
expectedError = error;
}

invariant(expectedError instanceof Error);
expect(expectedError.message).to.equal('Cannot count to 2');
expect(expectedError)
.to.be.an.instanceOf(Error)
.with.property('message', 'Cannot count to 2');

expect(await throwOver1.next()).to.deep.equal({
value: undefined,
Expand Down

0 comments on commit 5aba9c9

Please sign in to comment.