Skip to content

Commit 3c98214

Browse files
requested changes
1 parent 0f7d8ba commit 3c98214

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

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

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-empty-function */
22
import { expect } from 'chai';
33

4+
import { type Collection, type FindCursor, type MongoClient } from '../../mongodb';
45
import { type TestConfiguration } from '../../tools/runner/config';
56
import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder';
67

@@ -699,16 +700,24 @@ describe('MongoClient.close() Integration', () => {
699700

700701
describe('Server resource: Cursor', () => {
701702
describe('after cursors are created', () => {
702-
let client;
703-
let coll;
704-
let cursor;
705-
let utilClient;
703+
let client: MongoClient;
704+
let coll: Collection;
705+
let cursor: FindCursor;
706+
let utilClient: MongoClient;
706707

707708
beforeEach(async function () {
708709
client = this.configuration.newClient();
709710
utilClient = this.configuration.newClient();
710711
await client.connect();
711-
coll = await client.db('db').collection('coll', { capped: true, size: 1_000_000 });
712+
await client
713+
.db('db')
714+
.collection('coll')
715+
?.drop()
716+
.catch(() => null);
717+
coll = await client
718+
.db('db')
719+
.createCollection('coll', { capped: true, size: 1_000, max: 4 });
720+
await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]);
712721
});
713722

714723
afterEach(async function () {
@@ -717,7 +726,7 @@ describe('MongoClient.close() Integration', () => {
717726
await cursor?.close();
718727
});
719728

720-
it.skip('all active server-side cursors are closed by client.close()', async function () {
729+
it('all active server-side cursors are closed by client.close()', async function () {
721730
const getCursors = async () => {
722731
const res = await utilClient
723732
.db()
@@ -732,8 +741,7 @@ describe('MongoClient.close() Integration', () => {
732741
);
733742
};
734743

735-
await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]);
736-
cursor = await coll.find(
744+
cursor = coll.find(
737745
{},
738746
{
739747
tailable: true,

0 commit comments

Comments
 (0)