File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -1165,26 +1165,29 @@ describe('Collection', function () {
11651165 context (
11661166 'when serviceProvider.dropIndexes rejects IndexNotFound' ,
11671167 function ( ) {
1168+ let expectedError : Error ;
11681169 beforeEach ( function ( ) {
1169- const error = new Error ( 'index not found with name [index_1]' ) ;
1170- Object . assign ( error , {
1170+ expectedError = new Error ( 'index not found with name [index_1]' ) ;
1171+ Object . assign ( expectedError , {
11711172 ok : 0 ,
11721173 errmsg : 'index not found with name [index_1]' ,
11731174 code : 27 ,
11741175 codeName : 'IndexNotFound' ,
1175- name : 'MongoError ' ,
1176+ name : 'MongoServerError ' ,
11761177 } ) ;
11771178
1178- serviceProvider . runCommandWithCheck . rejects ( error ) ;
1179+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
11791180 } ) ;
11801181
11811182 it ( 'returns the error as object' , async function ( ) {
1182- expect ( await collection . dropIndexes ( 'index_1' ) ) . to . deep . equal ( {
1183- ok : 0 ,
1184- errmsg : 'index not found with name [index_1]' ,
1185- code : 27 ,
1186- codeName : 'IndexNotFound' ,
1187- } ) ;
1183+ let caughtError : Error | undefined ;
1184+ expect (
1185+ await collection
1186+ . dropIndexes ( 'index_1' )
1187+ . catch ( ( err ) => ( caughtError = err ) )
1188+ ) ;
1189+
1190+ expect ( caughtError ) . to . deep . equal ( expectedError ) ;
11881191 } ) ;
11891192 }
11901193 ) ;
You can’t perform that action at this time.
0 commit comments