-
Notifications
You must be signed in to change notification settings - Fork 66.9k
Expand file tree
/
Copy pathcode-annotations.ts
More file actions
32 lines (30 loc) · 1.27 KB
/
code-annotations.ts
File metadata and controls
32 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { describe, expect, test } from 'vitest'
import { runRule } from '../../lib/init-test'
import { codeAnnotations } from '../../lib/linting-rules/code-annotations'
describe(codeAnnotations.names.join(' - '), () => {
test('No layout property fails', async () => {
const markdown = ['---', 'title: Title', '---', '```shell annotate', 'hello', '```'].join('\n')
const result = await runRule(codeAnnotations, { strings: { markdown } })
const errors = result.markdown
expect(errors.length).toBe(1)
expect(errors[0].lineNumber).toBe(4)
expect(errors[0].errorRange).toEqual([1, 17])
expect(errors[0].fixInfo).toBeNull()
})
test('Incorrect layout property fails', async () => {
const markdown = ['---', 'layout: default', '---', '```shell annotate', 'hello', '```'].join(
'\n',
)
const result = await runRule(codeAnnotations, { strings: { markdown } })
const errors = result.markdown
expect(errors.length).toBe(1)
})
test('Correct layout property passes', async () => {
const markdown = ['---', 'layout: inline', '---', '```shell annotate', 'hello', '```'].join(
'\n',
)
const result = await runRule(codeAnnotations, { strings: { markdown } })
const errors = result.markdown
expect(errors.length).toBe(0)
})
})