-
-
Notifications
You must be signed in to change notification settings - Fork 57
Closed as not planned
Description
import { createHead, useHead } from '@unhead/vue'
import { createSSRApp, ref } from 'vue'
import { pipeToWebWritable } from '@vue/server-renderer'
import { renderSSRHead } from '@unhead/ssr'
import { describe, it, expect } from 'vitest'
const template = String.raw`<!doctype html><html lang="en"><!--head--><div id="app"><!--app--></div></html>`
describe('vue ssr', () => {
it('pipeToWebWritable', async () => {
const head = createHead()
const app = createSSRApp({
async setup() {
const title = ref('initial title')
useHead({
title,
})
await new Promise(resolve => setTimeout(resolve, 200))
title.value = 'new title'
return () => '<div>hi</div>'
},
})
app.use(head)
const [prepend, append] = template.split('<!--app-->')
const { headTags } = await renderSSRHead(head)
const encoder = new TextEncoder()
const { writable } = new TransformStream({
start(controller) {
// prepend.replace('<!--head-->', headTags)
controller.enqueue(encoder.encode(prepend))
},
flush(controller) {
controller.enqueue(encoder.encode(append))
}
})
pipeToWebWritable(app, {}, writable)
expect(headTags).eq('<title>new title</title>')
})
}) ❯ test/stream.test.js:29:22
27| await pipeToWebWritable(app, {}, writable)
28|
29| expect(headTags).eq('<title>new title</title>')
| ^
30| })
31| })
- Expected "<title>new title</title>"
+ Received ""Metadata
Metadata
Assignees
Labels
No labels