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
33
34
35
36
37
38
39
40
41
42
|
import { test, expect } from 'vitest'
import { withFixture } from '../common'
import * as path from 'path'
withFixture('basic', (c) => {
async function testDocumentLinks(name, { text, lang, expected }) {
test.concurrent(name, async () => {
let textDocument = await c.openDocument({ text, lang })
let res = await c.sendRequest('textDocument/documentLink', {
textDocument,
})
expect(res).toEqual(expected)
})
}
testDocumentLinks('file exists', {
text: '@config "tailwind.config.js";',
lang: 'css',
expected: [
{
target: `file://${path
.resolve('./tests/fixtures/basic/tailwind.config.js')
.replace(/@/g, '%40')}`,
range: { start: { line: 0, character: 8 }, end: { line: 0, character: 28 } },
},
],
})
testDocumentLinks('file does not exist', {
text: '@config "does-not-exist.js";',
lang: 'css',
expected: [
{
target: `file://${path
.resolve('./tests/fixtures/basic/does-not-exist.js')
.replace(/@/g, '%40')}`,
range: { start: { line: 0, character: 8 }, end: { line: 0, character: 27 } },
},
],
})
})
|