Skip to content

Commit

Permalink
test(NODE-3692): add type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Nov 9, 2021
1 parent 36e7a05 commit d6f29aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/types/mongodb.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MongoClient } from '../../src/mongo_client';
import { Collection } from '../../src/collection';
import { AggregationCursor } from '../../src/cursor/aggregation_cursor';
import type { FindCursor } from '../../src/cursor/find_cursor';
import type { ChangeStream, ChangeStreamDocument } from '../../src/change_stream';
import type { Document } from 'bson';
import { Db } from '../../src';
import { Topology } from '../../src/sdam/topology';
Expand Down Expand Up @@ -38,6 +39,16 @@ const composedMap = mappedAgg.map<string>(x => x.toString());
expectType<AggregationCursor<string>>(composedMap);
expectType<string | null>(await composedMap.next());
expectType<string[]>(await composedMap.toArray());
const changeStream = coll.watch();
changeStream.on('init', (doc) => {
expectType<Document>(doc);
});
changeStream.on('more', (doc) => {
expectType<Document | undefined>(doc);
});
changeStream.on('change', (doc) => {
expectType<ChangeStreamDocument<Document>>(doc);
});

const builtCursor = coll.aggregate();
// should allow string values for the out helper
Expand Down

0 comments on commit d6f29aa

Please sign in to comment.