11const path = require ( "path" ) ;
22const NextPage = require ( "../NextPage" ) ;
3+ const PluginBuildDir = require ( "../PluginBuildDir" ) ;
34
45describe ( "NextPage" , ( ) => {
56 describe ( "#constructor" , ( ) => {
67 it ( "should set a pagePath" , ( ) => {
7- const pagePath = "sls-next-build /home.js" ;
8+ const pagePath = ` ${ PluginBuildDir . BUILD_DIR_NAME } /home.js` ;
89 const page = new NextPage ( pagePath ) ;
910
1011 expect ( page . pagePath ) . toEqual ( pagePath ) ;
1112 } ) ;
1213 } ) ;
1314
1415 describe ( "When is the index page" , ( ) => {
15- const buildDir = "sls-next-build" ;
16+ const buildDir = PluginBuildDir . BUILD_DIR_NAME ;
1617 const pagePath = path . join ( buildDir , "index.js" ) ;
1718 let page ;
1819
@@ -33,7 +34,7 @@ describe("NextPage", () => {
3334 } ) ;
3435
3536 describe ( "When is the _error page" , ( ) => {
36- const buildDir = "sls-next-build" ;
37+ const buildDir = PluginBuildDir . BUILD_DIR_NAME ;
3738 const pagePath = path . join ( buildDir , "_error.js" ) ;
3839 let page ;
3940
@@ -58,7 +59,7 @@ describe("NextPage", () => {
5859 } ) ;
5960
6061 describe ( "When is a nested page" , ( ) => {
61- const buildDir = "sls-next-build" ;
62+ const buildDir = PluginBuildDir . BUILD_DIR_NAME ;
6263 const pagePath = path . join ( buildDir , "categories/fridge/fridges.js" ) ;
6364 let page ;
6465
@@ -81,7 +82,7 @@ describe("NextPage", () => {
8182 } ) ;
8283
8384 describe ( "When pagePath has win format" , ( ) => {
84- const buildDir = "sls-next-build" ;
85+ const buildDir = PluginBuildDir . BUILD_DIR_NAME ;
8586 const pagePath = `${ buildDir } \\admin.js` ;
8687 let page ;
8788
@@ -90,12 +91,14 @@ describe("NextPage", () => {
9091 } ) ;
9192
9293 it ( "should return posix pageHandler" , ( ) => {
93- expect ( page . pageHandler ) . toEqual ( "sls-next-build/admin.render" ) ;
94+ expect ( page . pageHandler ) . toEqual (
95+ `${ PluginBuildDir . BUILD_DIR_NAME } /admin.render`
96+ ) ;
9497 } ) ;
9598 } ) ;
9699
97100 describe ( "When the build directory is a subdirectory" , ( ) => {
98- const buildDir = path . join ( "app" , "sls-next-build" ) ;
101+ const buildDir = path . join ( "app" , PluginBuildDir . BUILD_DIR_NAME ) ;
99102 const pagePath = path . join ( buildDir , "admin.js" ) ;
100103 let page ;
101104
@@ -104,7 +107,9 @@ describe("NextPage", () => {
104107 } ) ;
105108
106109 it ( "should return pageHandler" , ( ) => {
107- expect ( page . pageHandler ) . toEqual ( "app/sls-next-build/admin.render" ) ;
110+ expect ( page . pageHandler ) . toEqual (
111+ `app/${ PluginBuildDir . BUILD_DIR_NAME } /admin.render`
112+ ) ;
108113 } ) ;
109114
110115 it ( "should return pageRoute" , ( ) => {
@@ -113,7 +118,7 @@ describe("NextPage", () => {
113118 } ) ;
114119
115120 describe ( "When a new instance is created" , ( ) => {
116- const buildDir = "sls-next-build" ;
121+ const buildDir = PluginBuildDir . BUILD_DIR_NAME ;
117122 const pagePath = `${ buildDir } /admin.js` ;
118123 let page ;
119124
@@ -142,7 +147,9 @@ describe("NextPage", () => {
142147 } ) ;
143148
144149 it ( "should return pageHandler" , ( ) => {
145- expect ( page . pageHandler ) . toEqual ( "sls-next-build/admin.render" ) ;
150+ expect ( page . pageHandler ) . toEqual (
151+ `${ PluginBuildDir . BUILD_DIR_NAME } /admin.render`
152+ ) ;
146153 } ) ;
147154
148155 it ( "should return pageFunctionName" , ( ) => {
0 commit comments