@@ -55,6 +55,20 @@ describe("Test plugin's lifecycle - buildStart", () => {
55
55
) ; // contain needed entry module
56
56
} ) ;
57
57
58
+ // TODO:
59
+ it ( "when template is exist in target path, should not be overwritten" , ( ) => {
60
+ // Do a generation
61
+ const filePath = path . join ( __dirname , "example" , "src" , "exist-template" , "index.html" ) ;
62
+ const configPath = path . join ( __dirname , "example" , "src" , "exist-template" , "config.json" ) ;
63
+ const configData = fs . readFileSync ( configPath , { encoding : "utf-8" } ) ;
64
+ expect ( fs . existsSync ( filePath ) ) . toBe ( true ) ; // temporary generated an entry HTML for build
65
+ const fileContent = fs . readFileSync ( filePath , { encoding : "utf-8" } ) ;
66
+ expect ( fileContent ) . toMatch ( "</html>" ) ; // correctly end html doc.
67
+ expect ( fileContent ) . toMatch (
68
+ `<title>This is an exist HTML</title>`
69
+ ) ; // correctly render ejs template with given data
70
+ } ) ;
71
+
58
72
// Skip EJS Option tests
59
73
} ) ;
60
74
@@ -68,8 +82,16 @@ describe("Test plugin's lifecycle - buildEnd", () => {
68
82
} )
69
83
70
84
it ( "temporary entries should be cleaned after calling `cleanTempEntries`" , ( ) => {
71
- entries . entries . forEach ( ( key ) => {
72
- expect ( fs . existsSync ( path . resolve ( key . abs + "/" + key . __options . templateName ) ) ) . toBe ( false ) ;
73
- } ) ;
85
+ const example = entries . entries . find ( key => key . value === 'subdir' )
86
+ expect ( example ) . not . toBeUndefined ( )
87
+ if ( example === undefined ) return ;
88
+ expect ( fs . existsSync ( path . resolve ( example . abs + "/" + example . __options . templateName ) ) ) . toBe ( false ) ;
89
+ } ) ;
90
+
91
+ // TODO:
92
+ it ( "template is not generated by plugin, should not be cleaned" , ( ) => {
93
+ // Do a generation
94
+ const filePath = path . join ( __dirname , "example" , "src" , "exist-template" , "index.html" ) ;
95
+ expect ( fs . existsSync ( filePath ) ) . toBe ( true ) ; // temporary generated an entry HTML for build
74
96
} ) ;
75
97
} ) ;
0 commit comments