@@ -17,10 +17,10 @@ const minify = require('..');
17
17
18
18
jest . mock ( 'terser' , ( ) => ( {
19
19
minify : jest . fn ( code => {
20
- return {
20
+ return Promise . resolve ( {
21
21
code : code . replace ( / ( ^ | \W ) \s + / g, '$1' ) ,
22
22
map : { } ,
23
- } ;
23
+ } ) ;
24
24
} ) ,
25
25
} ) ) ;
26
26
const { objectContaining} = expect ;
@@ -57,12 +57,12 @@ describe('Minification:', () => {
57
57
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
58
58
* error found when Flow v0.99 was deployed. To see the error, delete this
59
59
* comment and run Flow. */
60
- terser . minify . mockReturnValue ( { code : '' , map : '{}' } ) ;
60
+ terser . minify . mockResolvedValue ( { code : '' , map : '{}' } ) ;
61
61
map = getFakeMap ( ) ;
62
62
} ) ;
63
63
64
- it ( 'passes file name, code, and source map to `terser`' , ( ) => {
65
- minify ( {
64
+ it ( 'passes file name, code, and source map to `terser`' , async ( ) => {
65
+ await minify ( {
66
66
...baseOptions ,
67
67
code,
68
68
map,
@@ -80,21 +80,21 @@ describe('Minification:', () => {
80
80
) ;
81
81
} ) ;
82
82
83
- it ( 'returns the code provided by terser' , ( ) => {
83
+ it ( 'returns the code provided by terser' , async ( ) => {
84
84
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
85
85
* error found when Flow v0.99 was deployed. To see the error, delete this
86
86
* comment and run Flow. */
87
- terser . minify . mockReturnValue ( { code, map : '{}' } ) ;
88
- const result = minify ( baseOptions ) ;
87
+ terser . minify . mockResolvedValue ( { code, map : '{}' } ) ;
88
+ const result = await minify ( baseOptions ) ;
89
89
expect ( result . code ) . toBe ( code ) ;
90
90
} ) ;
91
91
92
- it ( 'parses the source map object provided by terser and sets the sources property' , ( ) => {
92
+ it ( 'parses the source map object provided by terser and sets the sources property' , async ( ) => {
93
93
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
94
94
* error found when Flow v0.99 was deployed. To see the error, delete this
95
95
* comment and run Flow. */
96
- terser . minify . mockReturnValue ( { map : JSON . stringify ( map ) , code : '' } ) ;
97
- const result = minify ( { ...baseOptions , filename} ) ;
96
+ terser . minify . mockResolvedValue ( { map : JSON . stringify ( map ) , code : '' } ) ;
97
+ const result = await minify ( { ...baseOptions , filename} ) ;
98
98
expect ( result . map ) . toEqual ( { ...map , sources : [ filename ] } ) ;
99
99
} ) ;
100
100
} ) ;
0 commit comments