test: binding component spacing · nuxt-content/mdc@ec49505

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,25 @@

1+

import { describe, expect, it } from 'vitest'

2+

import { parseMarkdown, stringifyMarkdown } from '../utils/parser'

3+
4+

describe('Markdown Binding', () => {

5+

const markdowns = [

6+

'{{ foo }}',

7+

'{{ foo || \'Foo\' }}',

8+

'{{ foo || \'Foo\' }}, bar',

9+

'{{ foo || \'Foo\' }}. bar',

10+

`Hello{{ name }}`,

11+

`Hello {{ name }}`,

12+

`Hello{{ name }},`,

13+

`Hello {{ name }},`,

14+

`Hello {{ name }} ,`

15+

]

16+
17+

for (const markdown of markdowns) {

18+

it(markdown, async () => {

19+

const ast = await parseMarkdown(markdown)

20+

const regenerated = await stringifyMarkdown(ast.body)

21+
22+

expect(regenerated?.trim()).toEqual(markdown)

23+

})

24+

}

25+

})