pengzhanbo 4464703b7b
test: add unit test (#262)
* test: add unit test

* chore: tweak

* chore: tweak
2024-10-12 02:09:15 +08:00

23 lines
752 B
TypeScript

import MarkdownIt from 'markdown-it'
import { describe, expect, it } from 'vitest'
import { plotPlugin } from '../src/node/inline/plot.js'
describe('plotPlugin', () => {
it('should work', () => {
const md = MarkdownIt().use(plotPlugin)
expect(md.render('!!plot!!')).toMatchSnapshot()
expect(md.render('hidden: !!plot!! **strong**')).toMatchSnapshot()
expect(md.render('hidden: \n!!plot!! \n!!plot!!')).toMatchSnapshot()
})
it('should not work with invalid tag', () => {
const md = MarkdownIt().use(plotPlugin)
expect(md.render('!!!!')).toMatchSnapshot()
expect(md.render('!!plot!')).toMatchSnapshot()
expect(md.render('!!!')).toMatchSnapshot()
expect(md.render('!! plot !!')).toMatchSnapshot()
})
})