@@ -4,16 +4,11 @@ import test from 'ava';
44
55const  fs  =  require ( 'fs' ) ; 
66const  rimraf  =  require ( 'rimraf' ) ; 
7- const  got  =  require ( 'got' ) ; 
87const  debug  =  require ( 'debug' ) ( 'node-chromium' ) ; 
98
109const  utils  =  require ( './utils' ) ; 
1110const  config  =  require ( './config' ) ; 
1211
13- const  install  =  async  ( )  =>  { 
14-     await  require ( './install' ) ; 
15- } ; 
16- 
1712test . before ( t  =>  { 
1813    // Deleting output folder 
1914    const  outPath  =  config . BIN_OUT_PATH ; 
@@ -34,54 +29,10 @@ test('Before Install Process', t => {
3429    t . false ( fs . existsSync ( binPath ) ,  `Chromium binary is found in: [${ binPath }  ) ; 
3530} ) ; 
3631
37- test ( 'Chromium Install' ,  async  t  =>  { 
38-     await  install ( ) ; 
39- 
40-     const  binPath  =  utils . getOsChromiumBinPath ( ) ; 
41-     const  isExists  =  fs . existsSync ( binPath ) ; 
42-     t . true ( isExists ,  `Chromium binary is not found in: [${ binPath }  ) ; 
43- } ) ; 
44- 
45- test . serial ( 'Different OS support' ,  async  t  =>  { 
46-     const  supportedPlatforms  =  [ 'darwin' ,  'linux' ,  'win32' ] ; 
47-     const  notSupportedPlatforms  =  [ 'aix' ,  'freebsd' ,  'openbsd' ,  'sunos' ] ; 
48- 
49-     const  originalPlatform  =  process . platform ; 
50- 
51-     for  ( const  platform  of  supportedPlatforms )  { 
52-         mockPlatform ( platform ) ; 
53- 
54-         const  revision  =  await  utils . getLatestRevisionNumber ( ) ; 
55- 
56-         const  url  =  utils . getDownloadUrl ( revision ) ; 
57-         t . true ( await  isUrlAccessible ( url ) ) ; 
58-     } 
59- 
60-     for  ( const  platform  of  notSupportedPlatforms )  { 
61-         mockPlatform ( platform ) ; 
62- 
63-         t . throws ( ( )  =>  { 
64-             utils . getDownloadUrl ( ) ; 
65-         } ,  'Unsupported platform' ) ; 
66-     } 
67- 
68-     mockPlatform ( originalPlatform ) ; 
69- 
70-     t . pass ( ) ; 
71- } ) ; 
72- 
73- async  function  isUrlAccessible ( url )  { 
74-     try  { 
75-         const  response  =  await  got ( url ,  { method : 'HEAD' } ) ; 
76-         return  / 4 \d \d / . test ( response . statusCode )  ===  false ; 
77-     }  catch  ( err )  { 
78-         console . warn ( `An error [${ err . message } ${ url }  ) ; 
79-         return  false ; 
80-     } 
81- } 
82- 
83- function  mockPlatform ( newPlatformValue )  { 
84-     Object . defineProperty ( process ,  'platform' ,  { 
85-         value : newPlatformValue 
32+ test ( 'Chromium Install' ,  t  =>  { 
33+     return  require ( './install' ) . then ( ( )  =>  { 
34+         const  binPath  =  utils . getOsChromiumBinPath ( ) ; 
35+         const  isExists  =  fs . existsSync ( binPath ) ; 
36+         t . true ( isExists ,  `Chromium binary is not found in: [${ binPath }  ) ; 
8637    } ) ; 
87- } 
38+ } ) ; 
0 commit comments