1-
21import rimraf from 'rimraf' ;
32import { execSync } from 'child_process' ;
43import { resolve } from 'path' ;
@@ -14,10 +13,15 @@ const createTest = function createTest(ext) {
1413 TEST_EXT : ext ,
1514 } ,
1615 } ) ;
17- stdout && console . log ( stdout ) ;
18- }
19- catch ( err ) {
20- err . stdout && console . error ( err . stdout ) ;
16+
17+ if ( stdout ) {
18+ console . log ( stdout ) ;
19+ }
20+ } catch ( err ) {
21+ if ( err . stdout ) {
22+ console . error ( err . stdout ) ;
23+ }
24+
2125 expect ( err ) . toBe ( undefined ) ;
2226 }
2327
@@ -29,11 +33,20 @@ const createTest = function createTest(ext) {
2933 require ( `./dist/${ ext } /app` ) ;
3034 require ( `./dist/${ ext } /pages/index/index` ) ;
3135 require ( `./dist/${ ext } /pages/logs/logs` ) ;
36+ require ( `./dist/${ ext } /pages/product/productDetail` ) ;
37+ require ( `./dist/${ ext } /pages/product/productList` ) ;
38+ require ( `./dist/${ ext } /pages/product2/productDetail` ) ;
39+ require ( `./dist/${ ext } /pages/product2/productList` ) ;
3240
3341 expect ( global . App . mock . calls . length ) . toBe ( 1 ) ;
34- expect ( global . Page . mock . calls . length ) . toBe ( 2 ) ;
42+ expect ( global . Page . mock . calls . length ) . toBe ( 6 ) ;
43+
44+ const getVendorPath = path => resolve ( __dirname , path , 'common.js' ) ;
45+ expect ( existsSync ( getVendorPath ( `dist/${ ext } /pages/product` ) ) ) . toBe ( true ) ;
46+ expect ( existsSync ( getVendorPath ( `dist/${ ext } /pages/product2` ) ) ) . toBe ( true ) ;
47+ expect ( existsSync ( getVendorPath ( `dist/${ ext } ` ) ) ) . toBe ( true ) ;
3548
36- const inImagesDir = ( name ) => resolve ( __dirname , `dist/${ ext } /images` , name ) ;
49+ const inImagesDir = name => resolve ( __dirname , `dist/${ ext } /images` , name ) ;
3750 expect ( existsSync ( inImagesDir ( 'wechat.png' ) ) ) . toBe ( true ) ;
3851 expect ( existsSync ( inImagesDir ( 'wechat_selected.png' ) ) ) . toBe ( true ) ;
3952 expect ( existsSync ( inImagesDir ( 'twitter.png' ) ) ) . toBe ( true ) ;
0 commit comments