1+ const path = require ( "path" ) ;
12const NextPage = require ( "../NextPage" ) ;
23
34describe ( "NextPage" , ( ) => {
@@ -12,7 +13,7 @@ describe("NextPage", () => {
1213
1314 describe ( "When is the index page" , ( ) => {
1415 const buildDir = "build" ;
15- const pagePath = ` ${ buildDir } / index.js` ;
16+ const pagePath = path . join ( buildDir , " index.js" ) ;
1617 let page ;
1718
1819 beforeEach ( ( ) => {
@@ -33,7 +34,7 @@ describe("NextPage", () => {
3334
3435 describe ( "When is the _error page" , ( ) => {
3536 const buildDir = "build" ;
36- const pagePath = ` ${ buildDir } / _error.js` ;
37+ const pagePath = path . join ( buildDir , " _error.js" ) ;
3738 let page ;
3839
3940 beforeEach ( ( ) => {
@@ -58,7 +59,7 @@ describe("NextPage", () => {
5859
5960 describe ( "When is a nested page" , ( ) => {
6061 const buildDir = "build" ;
61- const pagePath = ` ${ buildDir } / categories/fridge/fridges.js` ;
62+ const pagePath = path . join ( buildDir , " categories/fridge/fridges.js" ) ;
6263 let page ;
6364
6465 beforeEach ( ( ) => {
@@ -79,6 +80,20 @@ describe("NextPage", () => {
7980 } ) ;
8081 } ) ;
8182
83+ describe ( "When pagePath has win format" , ( ) => {
84+ const buildDir = "build" ;
85+ const pagePath = `${ buildDir } \\admin.js` ;
86+ let page ;
87+
88+ beforeEach ( ( ) => {
89+ page = new NextPage ( pagePath ) ;
90+ } ) ;
91+
92+ it ( "should return posix pageHandler" , ( ) => {
93+ expect ( page . pageHandler ) . toEqual ( "build/admin.render" ) ;
94+ } ) ;
95+ } ) ;
96+
8297 describe ( "When a new instance is created" , ( ) => {
8398 const buildDir = "build" ;
8499 const pagePath = `${ buildDir } /admin.js` ;
@@ -89,11 +104,15 @@ describe("NextPage", () => {
89104 } ) ;
90105
91106 it ( "should have pageCompatPath" , ( ) => {
92- expect ( page . pageCompatPath ) . toEqual ( `${ buildDir } /admin.compat.js` ) ;
107+ expect ( page . pageCompatPath ) . toEqual (
108+ path . join ( buildDir , "admin.compat.js" )
109+ ) ;
93110 } ) ;
94111
95112 it ( "should return pageOriginalPath" , ( ) => {
96- expect ( page . pageOriginalPath ) . toEqual ( `${ buildDir } /admin.original.js` ) ;
113+ expect ( page . pageOriginalPath ) . toEqual (
114+ path . join ( buildDir , "admin.original.js" )
115+ ) ;
97116 } ) ;
98117
99118 it ( "should return pageDir" , ( ) => {
0 commit comments