2022-11-30 13:50:29 +09:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
|
|
|
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(`
|
2023-01-16 04:09:01 +09:00
|
|
|
"text
|
|
|
|
\`\`\`js
|
|
|
|
code
|
|
|
|
\`\`\`"
|
|
|
|
`)
|
2022-11-30 13:50:29 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
it('bold & italic', () => {
|
|
|
|
expect(htmlToText('<p>text <b>bold</b> <em>italic</em></p>'))
|
|
|
|
.toMatchInlineSnapshot('"text **bold** *italic*"')
|
|
|
|
})
|
|
|
|
})
|