2022-12-05 07:59:04 +03:00
|
|
|
/**
|
|
|
|
* @vitest-environment jsdom
|
|
|
|
*/
|
2022-11-30 07:50:29 +03:00
|
|
|
import { describe, expect, it } from 'vitest'
|
2022-12-13 17:03:30 +03:00
|
|
|
import { htmlToText } from '~/composables/content-parse'
|
2022-11-30 07:50:29 +03:00
|
|
|
|
|
|
|
describe('html-to-text', () => {
|
|
|
|
it('inline code', () => {
|
|
|
|
expect(htmlToText('<p>text <code>code</code> inline</p>'))
|
|
|
|
.toMatchInlineSnapshot('"text `code` inline"')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('code block', () => {
|
|
|
|
expect(htmlToText('<p>text </p><pre><code class="language-js">code</code></pre>'))
|
|
|
|
.toMatchInlineSnapshot(`
|
|
|
|
"text
|
|
|
|
\`\`\`js
|
|
|
|
code
|
|
|
|
\`\`\`"
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('bold & italic', () => {
|
|
|
|
expect(htmlToText('<p>text <b>bold</b> <em>italic</em></p>'))
|
|
|
|
.toMatchInlineSnapshot('"text **bold** *italic*"')
|
|
|
|
})
|
|
|
|
})
|