Skip to content

Commit 3204c33

Browse files
committed
test(NODE-7204): add test for error
1 parent 3545016 commit 3204c33

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/integration/node-specific/cursor_stream.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { once } from 'node:events';
2+
13
import { expect } from 'chai';
24

3-
import { Binary, type Collection, type Db, type MongoClient } from '../../../src';
5+
import { Binary, type Collection, type Db, type MongoClient, MongoServerError } from '../../../src';
46
import { sleep } from '../../tools/utils';
57

6-
describe('Cursor Streams', function () {
8+
describe.only('Cursor Streams', function () {
79
let client: MongoClient;
810
let db: Db;
911

@@ -92,4 +94,19 @@ describe('Cursor Streams', function () {
9294
expect(docCount).to.equal(10);
9395
});
9496
});
97+
98+
it('should throws error', async function () {
99+
const cursor = db.collection('myCollection').find({
100+
timestamp: { $ltx: '1111' } // Error in query.
101+
});
102+
103+
const stream = cursor.stream();
104+
const onError = once(stream, 'error');
105+
stream.pipe(process.stdout);
106+
107+
const [error] = await onError;
108+
109+
expect(error).to.be.instanceof(MongoServerError);
110+
expect(error.message).to.include('unknown operator');
111+
});
95112
});

0 commit comments

Comments
 (0)