@@ -12,6 +12,8 @@ const glob = require('glob-promise');
12
12
const { JSDOM } = require ( 'jsdom' ) ;
13
13
const path = require ( 'path' ) ;
14
14
15
+ const mainBundleScriptRegex = / i n d e x .* .b u n d l e \. j s / ;
16
+
15
17
function publicDirectory ( label ) {
16
18
describe ( `Running Smoke Tests: ${ label } ` , function ( ) {
17
19
describe ( 'Public Directory Generated Output' , function ( ) {
@@ -43,15 +45,15 @@ function defaultNotFound(label) {
43
45
dom = await JSDOM . fromFile ( path . resolve ( this . context . publicDir , '404.html' ) ) ;
44
46
} ) ;
45
47
46
- it ( 'should have one bundle <script> tag in the <body>' , function ( ) {
48
+ it ( 'should have one <script> tag in the <body> for the main bundle ' , function ( ) {
47
49
const scriptTags = dom . window . document . querySelectorAll ( 'body script' ) ;
48
- const bundleScripts = Array . prototype . slice . call ( scriptTags ) . filter ( script => {
49
- const src = script . src ;
50
+ const bundledScript = Array . prototype . slice . call ( scriptTags ) . filter ( script => {
51
+ const src = script . src . replace ( 'file:///' , '' ) ;
50
52
51
- return src . indexOf ( 'index.' ) >= 0 && src . indexOf ( '.bundle.js' ) >= 0 ;
53
+ return mainBundleScriptRegex . test ( src ) ;
52
54
} ) ;
53
55
54
- expect ( bundleScripts . length ) . to . be . equal ( 1 ) ;
56
+ expect ( bundledScript . length ) . to . be . equal ( 1 ) ;
55
57
} ) ;
56
58
57
59
it ( 'should have a <title> tag in the <head>' , function ( ) {
@@ -86,15 +88,15 @@ function defaultIndex(label) {
86
88
expect ( title ) . to . be . equal ( 'Greenwood App' ) ;
87
89
} ) ;
88
90
89
- it ( 'should have one <script> tag for loading main JavaScript bundle at the end of the <body> tag ' , function ( ) {
91
+ it ( 'should have one <script> tag in the <body> for the main bundle ' , function ( ) {
90
92
const scriptTags = dom . window . document . querySelectorAll ( 'body eve-app ~ script' ) ;
91
- const bundleScripts = Array . prototype . slice . call ( scriptTags ) . filter ( script => {
92
- const src = script . src ;
93
+ const bundledScript = Array . prototype . slice . call ( scriptTags ) . filter ( script => {
94
+ const src = script . src . replace ( 'file:///' , '' ) ;
93
95
94
- return src . indexOf ( 'index' ) >= 0 && src . indexOf ( 'bundle' ) >= 0 ;
96
+ return mainBundleScriptRegex . test ( src ) ;
95
97
} ) ;
96
98
97
- expect ( bundleScripts . length ) . to . be . equal ( 1 ) ;
99
+ expect ( bundledScript . length ) . to . be . equal ( 1 ) ;
98
100
} ) ;
99
101
100
102
it ( 'should have a router outlet tag in the <body>' , function ( ) {
@@ -138,6 +140,7 @@ function defaultHelloPage(label) {
138
140
it ( 'should output a hello page directory' , function ( ) {
139
141
expect ( fs . existsSync ( path . join ( this . context . publicDir , './hello' ) ) ) . to . be . true ;
140
142
} ) ;
143
+
141
144
it ( 'should output an index.html file within the default hello page directory' , function ( ) {
142
145
expect ( fs . existsSync ( path . join ( this . context . publicDir , './hello' , './index.html' ) ) ) . to . be . true ;
143
146
} ) ;
0 commit comments