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

mapAsyncIterator-test: replace 'invariant' with expect chains #2679

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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