chore: setup unit test
This commit is contained in:
parent
410d41a0a8
commit
15733000a6
5 changed files with 220 additions and 2 deletions
21
tests/content.test.ts
Normal file
21
tests/content.test.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import type { Emoji } from 'masto'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { renderToString } from 'vue/server-renderer'
|
||||
import { contentToVNode } from '~/composables/content'
|
||||
|
||||
async function render(content: string, emojis?: Record<string, Emoji[]>) {
|
||||
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()
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue