Skip to content

Commit 1eda3f1

Browse files
Address PR comments
- use ts-expect-error instead of `as any` when purposely using an incorrect type - clean up new `it` block descriptions
1 parent f934f64 commit 1eda3f1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/unit/error.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// /* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
2-
31
import { expect } from 'chai';
42

53
import {
@@ -116,8 +114,8 @@ describe('MongoErrors', () => {
116114
});
117115

118116
describe('MongoSystemError#constructor', () => {
119-
context('when the topology description contains a code', () => {
120-
it('contains the code as a top level property', () => {
117+
context('when the topology description contains an error code', () => {
118+
it('contains the specified code as a top level property', () => {
121119
const topologyDescription = {
122120
error: {
123121
code: 123
@@ -129,8 +127,8 @@ describe('MongoErrors', () => {
129127
});
130128
});
131129

132-
context('when the topology description does not contain a code', () => {
133-
it('contains the code as a top level property', () => {
130+
context('when the topology description does not contain an error code', () => {
131+
it('contains the code as a top level property that is undefined', () => {
134132
const topologyDescription = { error: {} } as any as TopologyDescription;
135133

136134
const error = new MongoSystemError('something went wrong', topologyDescription);
@@ -139,7 +137,7 @@ describe('MongoErrors', () => {
139137
});
140138

141139
context('when the topology description does not contain an error property', () => {
142-
it('contains the code as a top level property', () => {
140+
it('contains the code as a top level property that is undefined', () => {
143141
const topologyDescription = {} as any as TopologyDescription;
144142

145143
const error = new MongoSystemError('something went wrong', topologyDescription);
@@ -262,7 +260,8 @@ describe('MongoErrors', () => {
262260
expect(getSymbolFrom(errorWithOptionFalse, 'beforeHandshake', false)).to.be.a('symbol');
263261

264262
const errorWithBadOption = new MongoNetworkError('', {
265-
beforeHandshake: 'not boolean' as any
263+
// @ts-expect-error: beforeHandshake must be a boolean value
264+
beforeHandshake: 'not boolean'
266265
});
267266
expect(getSymbolFrom(errorWithBadOption, 'beforeHandshake', false)).to.be.an('undefined');
268267

0 commit comments

Comments
 (0)