forked from nicojs/typed-html
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplified html stream generation
- Loading branch information
1 parent
bf1521f
commit 9b324af
Showing
21 changed files
with
238 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@kitajs/fastify-html-plugin': patch | ||
'@kitajs/html': patch | ||
--- | ||
|
||
Simplified html stream generation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import fastify from 'fastify'; | ||
import assert from 'node:assert'; | ||
import test from 'node:test'; | ||
import { fastifyKitaHtml } from '../'; | ||
|
||
test('opts.autoDoctype', async (t) => { | ||
await using app = fastify(); | ||
app.register(fastifyKitaHtml); | ||
|
||
app.get('/default', () => <div>Not a html root element</div>); | ||
app.get('/default/root', () => <html lang="en" />); | ||
app.get('/html', (_, res) => res.html(<div>Not a html root element</div>)); | ||
app.get('/html/root', (_, res) => res.html(<html lang="en" />)); | ||
|
||
await t.test('Default', async () => { | ||
const res = await app.inject({ method: 'GET', url: '/default' }); | ||
|
||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-type'], 'text/plain; charset=utf-8'); | ||
assert.strictEqual(res.body, '<div>Not a html root element</div>'); | ||
}); | ||
|
||
await t.test('Default root', async () => { | ||
const res = await app.inject({ method: 'GET', url: '/default/root' }); | ||
|
||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-type'], 'text/plain; charset=utf-8'); | ||
assert.strictEqual(res.body, '<html lang="en"></html>'); | ||
}); | ||
|
||
await t.test('Html ', async () => { | ||
const res = await app.inject({ method: 'GET', url: '/html' }); | ||
|
||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-type'], 'text/html; charset=utf-8'); | ||
assert.strictEqual(res.body, '<div>Not a html root element</div>'); | ||
}); | ||
|
||
await t.test('Html root', async () => { | ||
const res = await app.inject({ method: 'GET', url: '/html/root' }); | ||
|
||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-type'], 'text/html; charset=utf-8'); | ||
assert.strictEqual(res.body, '<!doctype html><html lang="en"></html>'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.