Skip to content

Commit b69286b

Browse files
committed
test: add where test
1 parent a46a919 commit b69286b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ describe('AbortSignal support', () => {
452452
expect(result).to.be.instanceOf(DOMException);
453453

454454
expect(cursorCommandSocket).to.have.property('destroyed', true);
455+
expect(cursor.closed).to.be.true;
455456
});
456457
}
457458

@@ -501,6 +502,8 @@ describe('AbortSignal support', () => {
501502
}
502503

503504
client.on('commandStarted', e => e.commandName === cursorName && controller.abort());
505+
let commandFailed = false;
506+
client.on('commandFailed', e => e.commandName === cursorName && (commandFailed = true));
504507
const willBeResultBlocked = iterateUntilDocumentOrError(cursor, cursorAPI, args);
505508

506509
const start = performance.now();
@@ -511,6 +514,8 @@ describe('AbortSignal support', () => {
511514
expect(result).to.be.instanceOf(DOMException);
512515

513516
expect(cursorCommandSocket).to.have.property('destroyed', true);
517+
expect(cursor.closed).to.be.true;
518+
expect(commandFailed).to.be.true;
514519
});
515520
}
516521

@@ -563,7 +568,7 @@ describe('AbortSignal support', () => {
563568
});
564569
});
565570

566-
describe.only('cursor $where example', () => {
571+
describe('cursor $where example', () => {
567572
beforeEach(async function () {
568573
const utilClient = this.configuration.newClient();
569574
try {
@@ -579,16 +584,17 @@ describe('AbortSignal support', () => {
579584
}
580585
});
581586

582-
it('follows expected stream error handling', async () => {
587+
it('throws an error from the cursor and ends the operation', async function () {
583588
const controller = new AbortController();
584589
const { signal } = controller;
585590
const cursor = collection.find(
586591
{
587-
$where: function () {
592+
//@ts-expect-error: our types do not support Code which should be fixed.
593+
$where: new Code(function () {
588594
while (true);
589-
}
595+
})
590596
},
591-
{ signal, batchSize: 1, serializeFunctions: true }
597+
{ signal, batchSize: 1 }
592598
);
593599

594600
client.on(

0 commit comments

Comments
 (0)