@@ -404,30 +404,34 @@ describe('DBSQLOperation', () => {
404
404
} ) ;
405
405
406
406
describe ( 'finished' , ( ) => {
407
- it ( 'should wait for finished state' , async ( ) => {
408
- const attemptsUntilFinished = 3 ;
409
-
410
- const handle = new OperationHandleMock ( ) ;
411
- const driver = new DriverMock ( ) ;
412
- driver . getOperationStatusResp . operationState = TOperationState . RUNNING_STATE ;
413
- sinon
414
- . stub ( driver , 'getOperationStatus' )
415
- . callThrough ( )
416
- . onCall ( attemptsUntilFinished - 1 ) // count is zero-based
417
- . callsFake ( ( ...args ) => {
418
- driver . getOperationStatusResp . operationState = TOperationState . FINISHED_STATE ;
419
- return driver . getOperationStatus . wrappedMethod . apply ( driver , args ) ;
420
- } ) ;
421
-
422
- const operation = new DBSQLOperation ( driver , handle ) ;
423
-
424
- expect ( operation . _status . state ) . to . equal ( TOperationState . INITIALIZED_STATE ) ;
407
+ [ TOperationState . INITIALIZED_STATE , TOperationState . RUNNING_STATE , TOperationState . PENDING_STATE ] . forEach (
408
+ ( operationState ) => {
409
+ it ( `should wait for finished state starting from TOperationState.${ TOperationState [ operationState ] } ` , async ( ) => {
410
+ const attemptsUntilFinished = 3 ;
411
+
412
+ const handle = new OperationHandleMock ( ) ;
413
+ const driver = new DriverMock ( ) ;
414
+ driver . getOperationStatusResp . operationState = operationState ;
415
+ sinon
416
+ . stub ( driver , 'getOperationStatus' )
417
+ . callThrough ( )
418
+ . onCall ( attemptsUntilFinished - 1 ) // count is zero-based
419
+ . callsFake ( ( ...args ) => {
420
+ driver . getOperationStatusResp . operationState = TOperationState . FINISHED_STATE ;
421
+ return driver . getOperationStatus . wrappedMethod . apply ( driver , args ) ;
422
+ } ) ;
423
+
424
+ const operation = new DBSQLOperation ( driver , handle ) ;
425
+
426
+ expect ( operation . _status . state ) . to . equal ( TOperationState . INITIALIZED_STATE ) ;
425
427
426
- await operation . finished ( ) ;
428
+ await operation . finished ( ) ;
427
429
428
- expect ( driver . getOperationStatus . callCount ) . to . be . equal ( attemptsUntilFinished ) ;
429
- expect ( operation . _status . state ) . to . equal ( TOperationState . FINISHED_STATE ) ;
430
- } ) ;
430
+ expect ( driver . getOperationStatus . callCount ) . to . be . equal ( attemptsUntilFinished ) ;
431
+ expect ( operation . _status . state ) . to . equal ( TOperationState . FINISHED_STATE ) ;
432
+ } ) ;
433
+ } ,
434
+ ) ;
431
435
432
436
it ( 'should pick up finished state from directResults' , async ( ) => {
433
437
const handle = new OperationHandleMock ( ) ;
@@ -473,7 +477,6 @@ describe('DBSQLOperation', () => {
473
477
TOperationState . CLOSED_STATE ,
474
478
TOperationState . ERROR_STATE ,
475
479
TOperationState . UKNOWN_STATE ,
476
- TOperationState . PENDING_STATE ,
477
480
TOperationState . TIMEDOUT_STATE ,
478
481
] . forEach ( ( operationState ) => {
479
482
it ( `should throw an error in case of a TOperationState.${ TOperationState [ operationState ] } ` , async ( ) => {
0 commit comments