(type: string, render: typeof renderToString)
| 66 | testRender(`pipeToNodeWritable`, pipeToWritable) |
| 67 | |
| 68 | function testRender(type: string, render: typeof renderToString) { |
| 69 | describe(`ssr: ${type}`, () => { |
| 70 | test('should apply app context', async () => { |
| 71 | const app = createApp({ |
| 72 | render() { |
| 73 | const Foo = resolveComponent('foo') as ComponentOptions |
| 74 | return h(Foo) |
| 75 | }, |
| 76 | }) |
| 77 | app.component('foo', { |
| 78 | render: () => h('div', 'foo'), |
| 79 | }) |
| 80 | const html = await render(app) |
| 81 | expect(html).toBe(`<div>foo</div>`) |
| 82 | }) |
| 83 | |
| 84 | test('warnings should be suppressed by app.config.warnHandler', async () => { |
| 85 | const app = createApp({ |
| 86 | render() { |
| 87 | return h('div', this.foo) |
| 88 | }, |
| 89 | }) |
| 90 | app.config.warnHandler = vi.fn() |
| 91 | await render(app) |
| 92 | expect('not defined on instance').not.toHaveBeenWarned() |
| 93 | expect(app.config.warnHandler).toHaveBeenCalledTimes(1) |
| 94 | }) |
| 95 | |
| 96 | describe('components', () => { |
| 97 | test('vnode components', async () => { |
| 98 | expect( |
| 99 | await render( |
| 100 | createApp({ |
| 101 | data() { |
| 102 | return { msg: 'hello' } |
| 103 | }, |
| 104 | render(this: any) { |
| 105 | return h('div', this.msg) |
| 106 | }, |
| 107 | }), |
| 108 | ), |
| 109 | ).toBe(`<div>hello</div>`) |
| 110 | }) |
| 111 | |
| 112 | test('option components returning render from setup', async () => { |
| 113 | expect( |
| 114 | await render( |
| 115 | createApp({ |
| 116 | setup() { |
| 117 | const msg = ref('hello') |
| 118 | return () => h('div', msg.value) |
| 119 | }, |
| 120 | }), |
| 121 | ), |
| 122 | ).toBe(`<div>hello</div>`) |
| 123 | }) |
| 124 | |
| 125 | test('setup components returning render from setup', async () => { |
no test coverage detected