Skip to content

Commit

Permalink
test: move new distinct comment falsy values tests into comment falsy…
Browse files Browse the repository at this point in the history
… value test file
  • Loading branch information
baileympearson committed Aug 2, 2022
1 parent b0cabc5 commit a096393
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 40 deletions.
39 changes: 38 additions & 1 deletion test/integration/node-specific/comment_with_falsy_values.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Long } from '../../../src';
import { expect } from 'chai';

import { Collection, CommandStartedEvent, Long, MongoClient } from '../../../src';
import { TestBuilder, UnifiedTestSuiteBuilder } from '../../tools/utils';

export const falsyValues = [0, false, '', Long.ZERO, null, NaN] as const;
Expand Down Expand Up @@ -173,4 +175,39 @@ describe('Comment with falsy values', () => {
.test(testsForChangeStreamsAggregate)
.test(testsForGetMore)
.run();

context('Collection.distinct()', function () {
let client: MongoClient;
let collection: Collection;
let commands: CommandStartedEvent[] = [];

beforeEach(async function () {
client = this.configuration.newClient({ monitorCommands: true });
client.on('commandStarted', e => commands.push(e));
await client.connect();
collection = await client.db('comment-falsy-values').createCollection('collection');
commands = [];
});

afterEach(async function () {
await collection.drop();
await client.close();
});

for (const falsyValue of falsyValues) {
it(`distinct should send falsy value ${falsyToString(
falsyValue
)} on the command`, async function () {
await collection.distinct('some-key', {}, { comment: falsyValue }).catch(() => null);

expect(commands).to.have.lengthOf(1);
const distinctCommand = commands.find(command => command.commandName === 'distinct');
expect(distinctCommand).to.exist;

// chai does not narrow types, so TS doesn't know the distinct command exists at this point.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
expect(distinctCommand!.command).to.haveOwnProperty('comment');
});
}
});
});
39 changes: 0 additions & 39 deletions test/integration/node-specific/distinct.test.ts

This file was deleted.

0 comments on commit a096393

Please sign in to comment.