-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathsnippets.test.ts
31 lines (28 loc) · 1.03 KB
/
snippets.test.ts
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
import { MarkupContent } from 'vscode-languageserver'
import { SNIPPETS } from '../snippets'
describe('snippets', () => {
it('should have unique labels', () => {
const labels = SNIPPETS.map((snippet) => snippet.label)
const uniqueLabels = new Set(labels)
expect(labels.length).toBe(uniqueLabels.size)
})
SNIPPETS.forEach(({ label, documentation }) => {
it(`contains the label in the documentation for "${label}"`, () => {
const stringDocumentation = (documentation as MarkupContent)?.value
expect(stringDocumentation).toBeDefined()
if (stringDocumentation) {
expect(stringDocumentation).toContain(label)
const secondLine = stringDocumentation.split('\n')[1]
try {
expect(
secondLine.startsWith(label) || secondLine.startsWith(`[${label}]`),
).toBe(true)
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Did not start with label: ${label}`, secondLine)
throw error
}
}
})
})
})