Skip to content

Commit 5aba9c9

Browse files
mapAsyncIterator-test: replace 'invariant' with expect chains (#2679)
1 parent 11505d7 commit 5aba9c9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/subscription/__tests__/mapAsyncIterator-test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import { expect } from 'chai';
44
import { describe, it } from 'mocha';
55

6-
import invariant from '../../jsutils/invariant';
7-
86
import mapAsyncIterator from '../mapAsyncIterator';
97

108
describe('mapAsyncIterator', () => {
@@ -271,8 +269,9 @@ describe('mapAsyncIterator', () => {
271269
caughtError = e;
272270
}
273271

274-
invariant(caughtError != null);
275-
expect(caughtError.message).to.equal('Goodbye');
272+
expect(caughtError)
273+
.to.be.an.instanceOf(Error)
274+
.with.property('message', 'Goodbye');
276275
});
277276

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

295294
const result = await doubles.next();
296-
invariant(result.value instanceof Error);
297-
expect(result.value.message).to.equal('Goodbye');
295+
expect(result.value)
296+
.to.be.an.instanceOf(Error)
297+
.with.property('message', 'Goodbye');
298298
expect(result.done).to.equal(false);
299299

300300
expect(await doubles.next()).to.deep.equal({
@@ -330,8 +330,9 @@ describe('mapAsyncIterator', () => {
330330
expectedError = error;
331331
}
332332

333-
invariant(expectedError instanceof Error);
334-
expect(expectedError.message).to.equal('Cannot count to 2');
333+
expect(expectedError)
334+
.to.be.an.instanceOf(Error)
335+
.with.property('message', 'Cannot count to 2');
335336

336337
expect(await throwOver1.next()).to.deep.equal({
337338
value: undefined,
@@ -375,8 +376,9 @@ describe('mapAsyncIterator', () => {
375376
expectedError = error;
376377
}
377378

378-
invariant(expectedError instanceof Error);
379-
expect(expectedError.message).to.equal('Cannot count to 2');
379+
expect(expectedError)
380+
.to.be.an.instanceOf(Error)
381+
.with.property('message', 'Cannot count to 2');
380382

381383
expect(await throwOver1.next()).to.deep.equal({
382384
value: undefined,

0 commit comments

Comments
 (0)