marked-mfm/test/index.test.js
Sol Fisher Romanoff 4d885754fd
Remove search
fuck search
2022-07-12 20:29:43 +03:00

44 lines
1.7 KiB
JavaScript

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 class="mfm _mfm_x2_" >this text is bigger</span></p>\n')
})
test('multiline', () => {
marked.use(markedMfm)
expect(marked('$[x2 line1\nline2]')).toBe('<p><span class="mfm _mfm_x2_" >line1\nline2</span></p>\n')
})
test('nested', () => {
marked.use(markedMfm)
expect(marked('$[x2 x2 $[sparkle sparkle]]')).toBe('<p><span class="mfm _mfm_x2_" >x2 <span class="mfm _mfm_sparkle_" >sparkle</span></span></p>\n')
})
test('lazy matching', () => {
marked.use(markedMfm)
expect(marked('$[x2 one] $[x2 two]')).toBe('<p><span class="mfm _mfm_x2_" >one</span> <span class="mfm _mfm_x2_" >two</span></p>\n')
})
test('nested & lazy matching', () => {
marked.use(markedMfm)
expect(marked('$[x2 one $[x2 two]] $[x2 three]')).toBe('<p><span class="mfm _mfm_x2_" >one <span class="mfm _mfm_x2_" >two</span></span> <span class="mfm _mfm_x2_" >three</span></p>\n')
})
test('invalid', () => {
marked.use(markedMfm)
expect(marked('$[invalid $[x2 test]]')).toBe('<p>$[invalid <span class="mfm _mfm_x2_" >test</span>]</p>\n')
})
test('one option', () => {
marked.use(markedMfm)
expect(marked('$[twitch.speed=2s test]')).toBe('<p><span class="mfm _mfm_twitch_" data-speed="2s">test</span></p>\n')
})
test('multiple options', () => {
marked.use(markedMfm)
expect(marked('$[spin.alternate,speed=0.5s test]')).toBe('<p><span class="mfm _mfm_spin_" data-alternate data-speed="0.5s">test</span></p>\n')
})
})