1+ import { type EventEmitter , once } from 'node:events' ;
2+ import { setTimeout } from 'node:timers' ;
3+
14import { expect } from 'chai' ;
2- import { type EventEmitter , once } from 'events' ;
35import * as sinon from 'sinon' ;
4- import { setTimeout } from 'timers' ;
56
67import {
7- addContainerMetadata ,
88 Binary ,
9- connect ,
10- Connection ,
119 type ConnectionOptions ,
12- HostAddress ,
13- LEGACY_HELLO_COMMAND ,
14- makeClientMetadata ,
1510 MongoClient ,
1611 MongoClientAuthProviders ,
1712 type MongoClientOptions ,
18- MongoDBResponse ,
1913 MongoServerError ,
20- ns ,
21- ServerHeartbeatStartedEvent ,
22- Topology
23- } from '../../mongodb' ;
14+ ServerHeartbeatStartedEvent
15+ } from '../../../src' ;
16+ import { connect } from '../../../src/cmap/connect' ;
17+ import { Connection } from '../../../src/cmap/connection' ;
18+ import {
19+ addContainerMetadata ,
20+ makeClientMetadata
21+ } from '../../../src/cmap/handshake/client_metadata' ;
22+ import { MongoDBResponse } from '../../../src/cmap/wire_protocol/responses' ;
23+ import { LEGACY_HELLO_COMMAND } from '../../../src/constants' ;
24+ import { Topology } from '../../../src/sdam/topology' ;
25+ import { HostAddress , ns } from '../../../src/utils' ;
2426import * as mock from '../../tools/mongodb-mock/index' ;
2527import { processTick , sleep } from '../../tools/utils' ;
2628import { assert as test , setupDatabase } from '../shared' ;
@@ -173,7 +175,7 @@ describe('Connection', function () {
173175 metadata : {
174176 requires : { topology : 'single' , os : '!win32' }
175177 } ,
176- test : function ( done ) {
178+ test : async function ( ) {
177179 const configuration = this . configuration ;
178180 const uri = `mongodb://${ encodeURIComponent ( '/tmp/mongodb-27017.sock' ) } ?w=1` ;
179181 const options : MongoClientOptions = {
@@ -186,22 +188,12 @@ describe('Connection', function () {
186188
187189 const db = client . db ( configuration . db ) ;
188190
189- db . collection ( 'domainSocketCollection0' ) . insert (
190- { a : 1 } ,
191- { writeConcern : { w : 1 } } ,
192- function ( err ) {
193- expect ( err ) . to . not . exist ;
194-
195- db . collection ( 'domainSocketCollection0' )
196- . find ( { a : 1 } )
197- . toArray ( function ( err , items ) {
198- expect ( err ) . to . not . exist ;
199- test . equal ( 1 , items . length ) ;
191+ await db
192+ . collection ( 'domainSocketCollection0' )
193+ . insertOne ( { a : 1 } , { writeConcern : { w : 1 } } ) ;
200194
201- done ( ) ;
202- } ) ;
203- }
204- ) ;
195+ const items = await db . collection ( 'domainSocketCollection0' ) . find ( { a : 1 } ) . toArray ( ) ;
196+ test . equal ( 1 , items . length ) ;
205197 }
206198 } ) ;
207199
0 commit comments