@@ -129,6 +129,63 @@ test('post files in a category', async t => {
129129 hasPaths ( t , categoryDir , compiledPostNames )
130130} )
131131
132+ test ( 'homepage' , async t => {
133+ const { exportDirectory, homepageDirectory } = writ . getDefaultSettings ( )
134+
135+ const dir = await createTempDir ( t )
136+ const rawHTMLHomepageContent = 'raw html homepage'
137+ await dir . mkFile ( 'index.html' , rawHTMLHomepageContent )
138+
139+ await writ . build ( {
140+ rootDirectory : dir . name
141+ } )
142+
143+ await common . builds ( t , dir . name , {
144+ rootDirectoryPaths : {
145+ exists : [ 'index.html' ]
146+ } ,
147+ exportDirectoryPaths : {
148+ exists : [ 'index.html' ]
149+ }
150+ } )
151+
152+ const actualRawHTMLOutputContent = await readFile ( join ( dir . name , exportDirectory , 'index.html' ) , { encoding : 'utf-8' } )
153+ const expectedRawHTMLOutputContent = new RegExp ( `^${ rawHTMLHomepageContent } $` , 's' )
154+ t . match (
155+ actualRawHTMLOutputContent ,
156+ expectedRawHTMLOutputContent ,
157+ "When homepage file has .html extension, it's treated as raw HTML"
158+ )
159+
160+ await rm ( join ( dir . name , 'index.html' ) )
161+
162+ const folderedHomepageContent = 'I am foldered homepage'
163+ await dir . mkDir ( homepageDirectory )
164+ await dir . mkFile ( join ( homepageDirectory , 'index.html' ) , folderedHomepageContent )
165+
166+ await writ . build ( {
167+ rootDirectory : dir . name
168+ } )
169+
170+ await common . builds ( t , dir . name , {
171+ rootDirectoryPaths : {
172+ exists : [ homepageDirectory ]
173+ } ,
174+ exportDirectoryPaths : {
175+ notExists : [ homepageDirectory ] ,
176+ exists : [ 'index.html' ]
177+ }
178+ } )
179+
180+ const actualFolderedOutputContent = await readFile ( join ( dir . name , exportDirectory , 'index.html' ) , { encoding : 'utf-8' } )
181+ const expectedFolderedOutputContent = new RegExp ( `^${ folderedHomepageContent } $` , 's' )
182+ t . match (
183+ actualFolderedOutputContent ,
184+ expectedFolderedOutputContent ,
185+ 'Using a homepage folder works'
186+ )
187+ } )
188+
132189test ( 'subpages' , async t => {
133190 const dir = await createTempDir ( t )
134191
0 commit comments