Skip to content

Commit

Permalink
test(NODE-3692): update to check TSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Nov 10, 2021
1 parent d6f29aa commit c9202b6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/types/mongodb.test-d.ts
Expand Up @@ -3,7 +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 { ChangeStreamDocument } from '../../src/change_stream';
import type { Document } from 'bson';
import { Db } from '../../src';
import { Topology } from '../../src/sdam/topology';
Expand All @@ -20,6 +20,9 @@ expectDeprecated(Db.prototype.unref);
expectDeprecated(MongoDBDriver.ObjectID);
expectNotDeprecated(MongoDBDriver.ObjectId);

interface TSchema extends Document {
}

// test mapped cursor types
const client = new MongoClient('');
const coll = client.db('test').collection('test');
Expand All @@ -40,14 +43,14 @@ 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('init', doc => {
expectType<TSchema>(doc);
});
changeStream.on('more', (doc) => {
expectType<Document | undefined>(doc);
changeStream.on('more', doc => {
expectType<TSchema | undefined>(doc);
});
changeStream.on('change', (doc) => {
expectType<ChangeStreamDocument<Document>>(doc);
changeStream.on('change', doc => {
expectType<ChangeStreamDocument<TSchema>>(doc);
});

const builtCursor = coll.aggregate();
Expand Down

0 comments on commit c9202b6

Please sign in to comment.