@@ -5,28 +5,53 @@ import * as fsExtra from 'fs-extra';
55import * as path from 'path' ;
66
77import { App } from '../src/lib/app' ;
8+ import * as cheerio from 'cheerio' ;
89
910const assert = chai . assert ;
1011describe ( 'App' , ( ) => {
1112 config ( ) ;
1213 const debug = ( process . env . TEST_DEBUG === 'true' ) ;
14+ describe ( '#changeMetaInIndex()' , ( ) => {
15+ const dir = path . resolve ( `${ __dirname } /fixture/apps/app1` ) ;
16+ const dirRoot = path . resolve ( __dirname + '/../' ) ;
17+ const srcIndexHtmlPath = path . resolve ( `${ dir } /src/index.html` ) ;
18+ beforeEach ( ( ) => {
19+ let srcIndexHtml = fsExtra . readFileSync ( srcIndexHtmlPath ) . toString ( ) ;
20+ const $ = cheerio . load ( srcIndexHtml ) ;
21+ $ ( 'meta[name=version]' ) . attr ( 'content' , '' ) ;
22+ srcIndexHtml = $ . html ( ) ;
23+ fsExtra . writeFileSync ( srcIndexHtmlPath , srcIndexHtml ) ;
24+ } ) ;
25+ it ( 'changeMetaInIndex' , ( done ) => {
26+ const app = new App ( dir , dirRoot ) ;
27+ app . debug = debug ;
28+ app . changeMetaInIndex ( ) . then ( ( data : any ) => {
29+ let srcIndexHtml = fsExtra . readFileSync ( srcIndexHtmlPath ) . toString ( ) ;
30+ const $ = cheerio . load ( srcIndexHtml ) ;
31+ assert . notEqual ( $ ( 'meta[name=version]' ) . attr ( 'content' ) , '' ) ;
32+ done ( ) ;
33+ } ) . catch ( ( e : any ) => {
34+ done ( e ) ;
35+ } ) ;
36+ } ) ;
37+ } ) ;
1338 describe ( '#makeTsList()' , ( ) => {
1439 const dir = path . resolve ( `${ __dirname } /fixture/apps/app1` ) ;
1540 const dirRoot = path . resolve ( __dirname + '/../' ) ;
16- const indexTsFile = path . resolve ( `${ dir } /src/app/index.ts` ) ;
41+ const srcIndexTsPath = path . resolve ( `${ dir } /src/app/index.ts` ) ;
1742 beforeEach ( ( ) => {
18- if ( fsExtra . existsSync ( indexTsFile ) ) {
19- del . sync ( [ indexTsFile ] ) ;
43+ if ( fsExtra . existsSync ( srcIndexTsPath ) ) {
44+ del . sync ( [ srcIndexTsPath ] ) ;
2045 }
2146 } ) ;
22- it ( `not exists ${ indexTsFile } ` , ( ) => {
23- assert . equal ( fsExtra . existsSync ( indexTsFile ) , false ) ;
47+ it ( `not exists ${ srcIndexTsPath } ` , ( ) => {
48+ assert . equal ( fsExtra . existsSync ( srcIndexTsPath ) , false ) ;
2449 } ) ;
2550 it ( 'srcgen -x -t make.list.ts.files -f ./srcgen/app1-make.list.ts.files.json' , ( done ) => {
2651 const app = new App ( dir , dirRoot ) ;
2752 app . debug = debug ;
2853 app . makeTsList ( ) . then ( ( data : any ) => {
29- assert . equal ( fsExtra . existsSync ( indexTsFile ) , true ) ;
54+ assert . equal ( fsExtra . existsSync ( srcIndexTsPath ) , true ) ;
3055 done ( ) ;
3156 } ) . catch ( ( e : any ) => {
3257 done ( e ) ;
@@ -82,27 +107,27 @@ describe('App', () => {
82107 const dir = path . resolve ( `${ __dirname } /fixture/apps/app1` ) ;
83108 const dirRoot = path . resolve ( __dirname + '/../' ) ;
84109 const translateTsFile = path . resolve ( `${ dir } /src/app/i18n/ru.i18n.ts` ) ;
85- const indexTsFile = path . resolve ( `${ dir } /src/app/index.ts` ) ;
110+ const srcIndexTsPath = path . resolve ( `${ dir } /src/app/index.ts` ) ;
86111 beforeEach ( ( ) => {
87112 if ( fsExtra . existsSync ( translateTsFile ) ) {
88113 del . sync ( [ translateTsFile ] ) ;
89114 }
90- if ( fsExtra . existsSync ( indexTsFile ) ) {
91- del . sync ( [ indexTsFile ] ) ;
115+ if ( fsExtra . existsSync ( srcIndexTsPath ) ) {
116+ del . sync ( [ srcIndexTsPath ] ) ;
92117 }
93118 } ) ;
94119 it ( `not exists ${ translateTsFile } ` , ( ) => {
95120 assert . equal ( fsExtra . existsSync ( translateTsFile ) , false ) ;
96121 } ) ;
97- it ( `not exists ${ indexTsFile } ` , ( ) => {
98- assert . equal ( fsExtra . existsSync ( indexTsFile ) , false ) ;
122+ it ( `not exists ${ srcIndexTsPath } ` , ( ) => {
123+ assert . equal ( fsExtra . existsSync ( srcIndexTsPath ) , false ) ;
99124 } ) ;
100125 it ( 'npm-run-all app1:tools-extract_translate app1:tools-po2ts app1:tools-make_ts_list' , ( done ) => {
101126 const app = new App ( dir , dirRoot ) ;
102127 app . debug = debug ;
103128 app . prepare ( ) . then ( ( data : any ) => {
104129 assert . equal ( fsExtra . existsSync ( translateTsFile ) , true ) ;
105- assert . equal ( fsExtra . existsSync ( indexTsFile ) , true ) ;
130+ assert . equal ( fsExtra . existsSync ( srcIndexTsPath ) , true ) ;
106131 done ( ) ;
107132 } ) . catch ( ( e : any ) => {
108133 done ( e ) ;
0 commit comments