Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/helper/ssg/ssg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,18 @@ describe('toSSG function', () => {
})

it('Should correctly generate files with the expected paths', async () => {
await toSSG(app, fsMock, { dir: './static' })
app.get('/data', (c) =>
c.text(JSON.stringify({ title: 'hono' }), 200, {
'Content-Type': 'application/json',
})
)
await toSSG(app, fsMock, {
dir: './static',
extensionMap: {
...defaultExtensionMap,
'application/json': 'json',
},
})

expect(fsMock.writeFile).toHaveBeenCalledWith('static/index.html', expect.any(String))
expect(fsMock.writeFile).toHaveBeenCalledWith('static/about.html', expect.any(String))
Expand All @@ -173,6 +184,7 @@ describe('toSSG function', () => {
expect(fsMock.writeFile).toHaveBeenCalledWith('static/about.html', expect.any(String))
expect(fsMock.writeFile).toHaveBeenCalledWith('static/bravo.html', expect.any(String))
expect(fsMock.writeFile).toHaveBeenCalledWith('static/Charlie.html', expect.any(String))
expect(fsMock.writeFile).toHaveBeenCalledWith('static/data.json', expect.any(String))
})

it('should modify the request if the hook is provided', async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/helper/ssg/ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ export const toSSG: ToSSGInterface = async (app, fs, options) => {
return
}
for (const content of getContentGen) {
savePromises.push(saveContentToFile(content, fs, outputDir).catch((e) => e))
savePromises.push(
saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e)
)
}
})
)
Expand Down
Loading