2022-11-25 17:25:56 +09:00
|
|
|
import type { Emoji } from 'masto'
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { renderToString } from 'vue/server-renderer'
|
|
|
|
import { contentToVNode } from '~/composables/content'
|
|
|
|
|
2022-11-25 17:30:38 +09:00
|
|
|
async function render(content: string, emojis?: Record<string, Emoji>) {
|
2022-11-25 17:25:56 +09:00
|
|
|
const vnode = contentToVNode(content, emojis)
|
|
|
|
const html = (await renderToString(vnode))
|
|
|
|
.replace(/<!--[\[\]]-->/g, '')
|
|
|
|
return {
|
|
|
|
vnode,
|
|
|
|
html,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('rich-content', () => {
|
|
|
|
it('plain', async () => {
|
|
|
|
const { html } = await render('Hello\nWorld')
|
|
|
|
expect(html).toMatchSnapshot()
|
|
|
|
})
|
|
|
|
})
|