mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import MarkdownIt from 'markdown-it'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { qrcodePlugin } from '../src/node/embed/qrcode.js'
|
|
|
|
describe('qrcodePlugin', () => {
|
|
it('should work with embed syntax', () => {
|
|
const md = MarkdownIt().use((md) => {
|
|
md.block.ruler.before('code', 'import_code', () => false)
|
|
md.renderer.rules.import_code = () => ''
|
|
}).use(qrcodePlugin)
|
|
|
|
expect(md.render('@[qrcode](text)')).toMatchSnapshot()
|
|
expect(md.render('@[qrcode svg card](text)')).toMatchSnapshot()
|
|
expect(md.render('@[qrcode title="title"](text)')).toMatchSnapshot()
|
|
})
|
|
|
|
it('should not work with container syntax', () => {
|
|
const md = MarkdownIt().use((md) => {
|
|
md.block.ruler.before('code', 'import_code', () => false)
|
|
md.renderer.rules.import_code = () => ''
|
|
}).use(qrcodePlugin)
|
|
|
|
expect(md.render(':::qrcode\ntext\n:::')).toMatchSnapshot()
|
|
expect(md.render(':::qrcode svg card\ntext\n:::')).toMatchSnapshot()
|
|
expect(md.render(':::qrcode title="title"\ntext\n:::')).toMatchSnapshot()
|
|
})
|
|
})
|