1
- import { logger , FlexPluginError } from 'flex-dev-utils' ;
2
1
import * as run from '../run' ;
3
2
4
3
jest . mock ( 'flex-dev-utils/dist/logger' ) ;
@@ -15,60 +14,6 @@ describe('run', () => {
15
14
process . env = { ...OLD_ENV } ;
16
15
} ) ;
17
16
18
- it ( 'should run successfully' , async ( ) => {
19
- const cb = jest . fn ( ) ;
20
- await run . default ( cb ) ;
21
-
22
- expect ( cb ) . toHaveBeenCalledTimes ( 1 ) ;
23
- } ) ;
24
-
25
- it ( 'should log normal error if not a FlexPluginError' , async ( ) => {
26
- const err = new Error ( 'error-message' ) ;
27
- const cb = jest . fn ( ) . mockImplementation ( ( ) => {
28
- throw err ;
29
- } ) ;
30
-
31
- await run . default ( cb ) ;
32
-
33
- expect ( exit ) . toHaveBeenCalledTimes ( 1 ) ;
34
- expect ( exit ) . toHaveBeenCalledWith ( 1 ) ;
35
- expect ( logger . error ) . toHaveBeenCalledTimes ( 1 ) ;
36
- expect ( logger . error ) . toHaveBeenCalledWith ( err ) ;
37
- } ) ;
38
-
39
- it ( 'should log FlexPluginError print' , async ( ) => {
40
- const err = new FlexPluginError ( 'another-error' ) ;
41
- const print = jest . spyOn ( err , 'print' ) ;
42
- const details = jest . spyOn ( err , 'details' ) ;
43
- const cb = jest . fn ( ) . mockImplementation ( ( ) => {
44
- throw err ;
45
- } ) ;
46
-
47
- await run . default ( cb ) ;
48
-
49
- expect ( exit ) . toHaveBeenCalledTimes ( 1 ) ;
50
- expect ( exit ) . toHaveBeenCalledWith ( 1 ) ;
51
- expect ( print ) . toHaveBeenCalledTimes ( 1 ) ;
52
- expect ( details ) . not . toHaveBeenCalled ( ) ;
53
- } ) ;
54
-
55
- it ( 'should also log details of FlexPluginError' , async ( ) => {
56
- const err = new FlexPluginError ( 'another-error' ) ;
57
- const print = jest . spyOn ( err , 'print' ) ;
58
- const details = jest . spyOn ( err , 'details' ) ;
59
- const cb = jest . fn ( ) . mockImplementation ( ( ) => {
60
- throw err ;
61
- } ) ;
62
- process . env . DEBUG = 'true' ;
63
-
64
- await run . default ( cb ) ;
65
-
66
- expect ( exit ) . toHaveBeenCalledTimes ( 1 ) ;
67
- expect ( exit ) . toHaveBeenCalledWith ( 1 ) ;
68
- expect ( print ) . toHaveBeenCalledTimes ( 1 ) ;
69
- expect ( details ) . toHaveBeenCalledTimes ( 1 ) ;
70
- } ) ;
71
-
72
17
describe ( 'exit' , ( ) => {
73
18
it ( 'should not quit if arg has the flag' , ( ) => {
74
19
run . exit ( 123 , [ '--no-process-exit' ] ) ;
0 commit comments