@@ -24,68 +24,36 @@ function createConfig() {
2424 return new WebpackConfig ( runtimeConfig ) ;
2525}
2626
27- /**
28- * Some tests are very specific to different operating systems.
29- * We use this to only run them when needed.
30- *
31- * @returns {boolean }
32- */
33- function isWindows ( ) {
34- return process . platform === 'win32' ;
35- }
27+ const isWindows = ( process . platform === 'win32' ) ;
3628
3729describe ( 'path-util getContentBase()' , ( ) => {
3830 describe ( 'getContentBase()' , ( ) => {
3931 it ( 'contentBase is calculated correctly' , function ( ) {
40- if ( isWindows ( ) ) {
41- this . skip ( ) ;
42- }
43-
4432 const config = createConfig ( ) ;
4533 config . runtimeConfig . useDevServer = true ;
4634 config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
47- config . outputPath = '/tmp/public/build' ;
35+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
4836 config . setPublicPath ( '/build/' ) ;
4937 config . addEntry ( 'main' , './main' ) ;
5038
5139 const actualContentBase = pathUtil . getContentBase ( config ) ;
5240 // contentBase should point to the "document root", which
5341 // is calculated as outputPath, but without the publicPath portion
54- expect ( actualContentBase ) . to . equal ( '/tmp/public' ) ;
42+ expect ( actualContentBase ) . to . equal ( isWindows ? 'C:\\tmp\\public' : '/tmp/public' ) ;
5543 } ) ;
5644
5745 it ( 'contentBase works ok with manifestKeyPrefix' , function ( ) {
58- if ( isWindows ( ) ) {
59- this . skip ( ) ;
60- }
61-
6246 const config = createConfig ( ) ;
6347 config . runtimeConfig . useDevServer = true ;
6448 config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
65- config . outputPath = '/tmp/public/build' ;
49+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
6650 config . setPublicPath ( '/subdirectory/build' ) ;
6751 // this "fixes" the incompatibility between outputPath and publicPath
6852 config . setManifestKeyPrefix ( '/build/' ) ;
6953 config . addEntry ( 'main' , './main' ) ;
7054
7155 const actualContentBase = pathUtil . getContentBase ( config ) ;
72- expect ( actualContentBase ) . to . equal ( '/tmp/public' ) ;
73- } ) ;
74-
75- it ( 'contentBase is calculated correctly on Windows' , function ( ) {
76- if ( ! isWindows ( ) ) {
77- this . skip ( ) ;
78- }
79-
80- const config = createConfig ( ) ;
81- config . runtimeConfig . useDevServer = true ;
82- config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
83- config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
84- config . setPublicPath ( '/build/' ) ;
85- config . addEntry ( 'main' , './main' ) ;
86-
87- const actualContentBase = pathUtil . getContentBase ( config ) ;
88- expect ( actualContentBase ) . to . equal ( 'C:\\projects\\webpack-encore\\public' ) ;
56+ expect ( actualContentBase ) . to . equal ( isWindows ? 'C:\\tmp\\public' : '/tmp/public' ) ;
8957 } ) ;
9058 } ) ;
9159
@@ -114,7 +82,8 @@ describe('path-util getContentBase()', () => {
11482
11583 it ( 'when outputPath and publicPath are incompatible, manifestKeyPrefix must be set' , ( ) => {
11684 const config = createConfig ( ) ;
117- config . outputPath = '/tmp/public/build' ;
85+
86+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
11887 config . addEntry ( 'main' , './main' ) ;
11988 // pretend we're installed to a subdirectory
12089 config . setPublicPath ( '/subdirectory/build' ) ;
@@ -126,30 +95,18 @@ describe('path-util getContentBase()', () => {
12695 } ) ;
12796
12897 describe ( 'getRelativeOutputPath' , ( ) => {
129- it ( 'Works with Unix paths' , function ( ) {
130- if ( isWindows ( ) ) {
131- this . skip ( ) ;
132- }
133-
98+ it ( 'basic usage' , function ( ) {
13499 const config = createConfig ( ) ;
135- config . runtimeConfig . context = '/tmp/webpack-encore' ;
136- config . outputPath = '/tmp/webpack-encore/public/build' ;
137-
138- const actualPath = pathUtil . getRelativeOutputPath ( config ) ;
139- expect ( actualPath ) . to . equal ( 'public/build' ) ;
140- } ) ;
141-
142- it ( 'Works with Windows paths' , function ( ) {
143- if ( ! isWindows ( ) ) {
144- this . skip ( ) ;
100+ if ( isWindows ) {
101+ config . runtimeConfig . context = 'C:\\projects\\webpack-encore' ;
102+ config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
103+ } else {
104+ config . runtimeConfig . context = '/tmp/webpack-encore' ;
105+ config . outputPath = '/tmp/webpack-encore/public/build' ;
145106 }
146107
147- const config = createConfig ( ) ;
148- config . runtimeConfig . context = 'C:\\projects\\webpack-encore' ;
149- config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
150-
151108 const actualPath = pathUtil . getRelativeOutputPath ( config ) ;
152- expect ( actualPath ) . to . equal ( 'public\\build' ) ;
109+ expect ( actualPath ) . to . equal ( isWindows ? 'public\\build' : 'public/ build') ;
153110 } ) ;
154111 } ) ;
155112} ) ;
0 commit comments