@@ -713,20 +713,33 @@ describe('Device', () => {
713
713
expect ( driverMock . driver . cleanup ) . toHaveBeenCalledTimes ( 1 ) ;
714
714
} ) ;
715
715
716
- it ( `_cleanup() should not shutdown the device by default` , async ( ) => {
716
+ it ( `_cleanup() should shutdown a prepared device if --cleanup is passed from CLI` , async ( ) => {
717
+ argparse . getArgValue . mockReturnValue ( true ) ;
718
+
719
+ const device = validDevice ( ) ;
720
+ await device . prepare ( ) ;
721
+ await device . _cleanup ( ) ;
722
+
723
+ expect ( driverMock . driver . shutdown ) . toHaveBeenCalled ( ) ;
724
+ } ) ;
725
+
726
+ it ( `_cleanup() should not shutdown a prepared device if --cleanup is not passed from CLI` , async ( ) => {
727
+ argparse . getArgValue . mockReturnValue ( false ) ;
728
+
717
729
const device = validDevice ( ) ;
730
+ await device . prepare ( ) ;
718
731
await device . _cleanup ( ) ;
719
732
720
733
expect ( driverMock . driver . shutdown ) . not . toHaveBeenCalled ( ) ;
721
734
} ) ;
722
735
723
- it ( `_cleanup() should shutdown the device if --cleanup is passed form CLI` , async ( ) => {
736
+ it ( `_cleanup() should not shutdown an unprepared device even if --cleanup is passed from CLI` , async ( ) => {
724
737
argparse . getArgValue . mockReturnValue ( true ) ;
725
738
726
739
const device = validDevice ( ) ;
727
740
await device . _cleanup ( ) ;
728
741
729
- expect ( driverMock . driver . shutdown ) . toHaveBeenCalledTimes ( 1 ) ;
742
+ expect ( driverMock . driver . shutdown ) . not . toHaveBeenCalled ( ) ;
730
743
} ) ;
731
744
732
745
it ( `new Device() with invalid device config (no binary) should throw` , ( ) => {
0 commit comments