@@ -51,7 +51,7 @@ describe('Connect Tests', function () {
51
51
52
52
afterEach ( ( ) => mock . cleanup ( ) ) ;
53
53
54
- it ( 'should auth against a non-arbiter' , function ( done ) {
54
+ it ( 'should auth against a non-arbiter' , async function ( ) {
55
55
const whatHappened = { } ;
56
56
57
57
test . server . setMessageHandler ( request => {
@@ -71,19 +71,13 @@ describe('Connect Tests', function () {
71
71
}
72
72
} ) ;
73
73
74
- connect ( test . connectOptions , err => {
75
- try {
76
- expect ( whatHappened ) . to . have . property ( LEGACY_HELLO_COMMAND , true ) ;
77
- expect ( whatHappened ) . to . have . property ( 'saslStart' , true ) ;
78
- } catch ( _err ) {
79
- err = _err ;
80
- }
74
+ await connect ( test . connectOptions ) ;
81
75
82
- done ( err ) ;
83
- } ) ;
76
+ expect ( whatHappened ) . to . have . property ( LEGACY_HELLO_COMMAND , true ) ;
77
+ expect ( whatHappened ) . to . have . property ( 'saslStart' , true ) ;
84
78
} ) ;
85
79
86
- it ( 'should not auth against an arbiter' , function ( done ) {
80
+ it ( 'should not auth against an arbiter' , async function ( ) {
87
81
const whatHappened = { } ;
88
82
test . server . setMessageHandler ( request => {
89
83
const doc = request . document ;
@@ -102,16 +96,10 @@ describe('Connect Tests', function () {
102
96
}
103
97
} ) ;
104
98
105
- connect ( test . connectOptions , err => {
106
- try {
107
- expect ( whatHappened ) . to . have . property ( LEGACY_HELLO_COMMAND , true ) ;
108
- expect ( whatHappened ) . to . not . have . property ( 'saslStart' ) ;
109
- } catch ( _err ) {
110
- err = _err ;
111
- }
99
+ await connect ( test . connectOptions ) ;
112
100
113
- done ( err ) ;
114
- } ) ;
101
+ expect ( whatHappened ) . to . have . property ( LEGACY_HELLO_COMMAND , true ) ;
102
+ expect ( whatHappened ) . to . not . have . property ( 'saslStart' ) ;
115
103
} ) ;
116
104
} ) ;
117
105
@@ -133,10 +121,7 @@ describe('Connect Tests', function () {
133
121
socketTimeoutMS : 15000
134
122
} ;
135
123
136
- connection = await promisify < Connection > ( callback =>
137
- //@ts -expect-error: Callbacks do not have mutual exclusion for error/result existence
138
- connect ( connectOptions , callback )
139
- ) ( ) ;
124
+ connection = await connect ( connectOptions ) ;
140
125
} ) ;
141
126
142
127
afterEach ( async ( ) => {
@@ -166,19 +151,13 @@ describe('Connect Tests', function () {
166
151
} ) ;
167
152
} ) ;
168
153
169
- const error = await promisify < Connection > ( callback =>
170
- connect (
171
- {
172
- ...connectOptions ,
173
- // Ensure these timeouts do not fire first
174
- socketTimeoutMS : 5000 ,
175
- connectTimeoutMS : 5000 ,
176
- cancellationToken
177
- } ,
178
- //@ts -expect-error: Callbacks do not have mutual exclusion for error/result existence
179
- callback
180
- )
181
- ) ( ) . catch ( error => error ) ;
154
+ const error = await connect ( {
155
+ ...connectOptions ,
156
+ // Ensure these timeouts do not fire first
157
+ socketTimeoutMS : 5000 ,
158
+ connectTimeoutMS : 5000 ,
159
+ cancellationToken
160
+ } ) . catch ( error => error ) ;
182
161
183
162
expect ( error , error . stack ) . to . match ( / c o n n e c t i o n e s t a b l i s h m e n t w a s c a n c e l l e d / ) ;
184
163
} ) ;
@@ -189,21 +168,20 @@ describe('Connect Tests', function () {
189
168
// set no response handler for mock server, effectively black hole requests
190
169
server . setMessageHandler ( ( ) => null ) ;
191
170
192
- const error = await promisify < Connection > ( callback =>
193
- //@ts -expect-error: Callbacks do not have mutual exclusion for error/result existence
194
- connect ( { ...connectOptions , connectTimeoutMS : 5 } , callback )
195
- ) ( ) . catch ( error => error ) ;
171
+ const error = await connect ( { ...connectOptions , connectTimeoutMS : 5 } ) . catch (
172
+ error => error
173
+ ) ;
196
174
197
175
expect ( error ) . to . match ( / t i m e d o u t / ) ;
198
176
} ) ;
199
177
} ) ;
200
178
} ) ;
201
179
202
- it ( 'should emit `MongoNetworkError` for network errors' , function ( done ) {
203
- connect ( { hostAddress : new HostAddress ( 'non-existent:27018' ) } , err => {
204
- expect ( err ) . to . be . instanceOf ( MongoNetworkError ) ;
205
- done ( ) ;
206
- } ) ;
180
+ it ( 'should emit `MongoNetworkError` for network errors' , async function ( ) {
181
+ const error = await connect ( {
182
+ hostAddress : new HostAddress ( 'non-existent:27018' )
183
+ } ) . catch ( e => e ) ;
184
+ expect ( error ) . to . be . instanceOf ( MongoNetworkError ) ;
207
185
} ) ;
208
186
209
187
context ( 'prepareHandshakeDocument' , ( ) => {
0 commit comments