Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix for ts-node strangeness
  • Loading branch information
nbbeeken committed Sep 2, 2022
commit 144b03b9332b5bae7b8c6e35d66d0292e1cdfe4b
24 changes: 21 additions & 3 deletions test/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import { inspect } from 'util';

import * as mongodb from '../../lib/index';
import * as mongodb from '../../src/index';
import { setDifference } from '../../src/utils';
import { byStrings, sorted } from '../tools/utils';

Expand Down Expand Up @@ -126,6 +125,10 @@ const expectedExports = new Map([
['GridFSBucketWriteStream', 'reason'],
['OrderedBulkOperation', 'reason'],
['UnorderedBulkOperation', 'reason'],

// TS-NODE Adds these keys but they are undefined... weird
Comment thread
dariakp marked this conversation as resolved.
Outdated
['AnyBulkWriteOperation', 'ts-node'],
['BulkWriteOptions', 'ts-node'],
]);

describe('mongodb entrypoint', () => {
Expand All @@ -138,6 +141,21 @@ describe('mongodb entrypoint', () => {
it('should export only keys in our exports list', () => {
const currentExports = Object.keys(mongodb);
const difference = setDifference(currentExports, expectedExports.keys());
expect(difference, inspect(difference, { breakLength: Infinity })).to.have.lengthOf(0);
expect(
difference,
`Found extra exports [${Array.from(difference).join(
Comment thread
dariakp marked this conversation as resolved.
Outdated
', '
)}], if these are expected, just add them to the list in this file`
).to.have.lengthOf(0);
});

it('meta test: ts-node adds keys to the module that point to undefined', () => {
Comment thread
dariakp marked this conversation as resolved.
Outdated
const tsNodeKeys = Array.from(expectedExports.entries()).filter(
([, value]) => value === 'ts-node'
);

for (const [tsNodeKey] of tsNodeKeys) {
expect(mongodb).to.have.property(tsNodeKey, undefined);
}
});
});