marked-mfm/test/index.test.js

35 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-07-08 08:32:20 +00:00
import { marked } from 'marked'
import markedMfm from '../src/index.js'
describe('marked-mfm', () => {
test('inline', () => {
marked.use(markedMfm)
expect(marked('$[x2 this text is bigger]')).toBe('<p><span style="display: inline-block;" class="_mfm_x2_">this text is bigger</span></p>\n')
2022-07-08 08:32:20 +00:00
})
test('nested', () => {
marked.use(markedMfm)
expect(marked('$[x2 x2 $[sparkle sparkle]]')).toBe('<p><span style="display: inline-block;" class="_mfm_x2_">x2 <span style="display: inline-block;" class="_mfm_sparkle_">sparkle</span></span></p>\n')
2022-07-08 08:32:20 +00:00
})
2022-07-08 08:59:00 +00:00
test('invalid', () => {
marked.use(markedMfm)
expect(marked('$[invalid $[x2 test]]')).toBe('<p>$[invalid <span style="display: inline-block;" class="_mfm_x2_">test</span>]</p>\n')
2022-07-08 09:59:28 +00:00
})
test('one option', () => {
marked.use(markedMfm)
expect(marked('$[twitch.speed=2s test]')).toBe('<p><span style="display: inline-block; animation: mfm-twitch 2s ease infinite;" class="_mfm_twitch_">test</span></p>\n')
2022-07-08 09:59:28 +00:00
})
test('multiple options', () => {
marked.use(markedMfm)
expect(marked('$[spin.alternate,speed=0.5s test]')).toBe('<p><span style="display: inline-block; animation: mfm-spin 0.5s linear infinite; animation-direction: alternate;" class="_mfm_spin_">test</span></p>\n')
2022-07-08 08:59:00 +00:00
})
2022-07-08 10:33:03 +00:00
test('search', () => {
marked.use(markedMfm)
expect(marked('syuilo thighs search')).toBe('<a href="https://google.com/search?q=syuilo thighs" class="_mfm_search_">syuilo thighs search</a>')
2022-07-08 10:33:03 +00:00
})
2022-07-08 08:32:20 +00:00
})