-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsyntactic-diagnostics.test.ts
More file actions
76 lines (75 loc) · 1.8 KB
/
syntactic-diagnostics.test.ts
File metadata and controls
76 lines (75 loc) · 1.8 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import dedent from 'dedent';
import { expect, test } from 'vite-plus/test';
import { createIFF } from '../test-util/fixture.js';
import { launchTsserver } from '../test-util/tsserver.js';
test('Syntactic Diagnostics', async () => {
const tsserver = launchTsserver();
const iff = await createIFF({
'a.module.css': dedent`
@value;
:local(:global(.a_1)) { color: red; }
:local .a_2 { color: red; }
`,
'tsconfig.json': dedent`
{
"compilerOptions": {},
"cmkOptions": {
"enabled": true,
"dtsOutDir": "generated"
}
}
`,
});
await tsserver.sendUpdateOpen({
openFiles: [{ file: iff.paths['a.module.css'] }],
});
const res1 = await tsserver.sendSyntacticDiagnosticsSync({
file: iff.paths['a.module.css'],
});
expect(res1.body).toMatchInlineSnapshot(`
[
{
"category": "error",
"code": 0,
"end": {
"line": 1,
"offset": 8,
},
"source": "css-modules-kit",
"start": {
"line": 1,
"offset": 1,
},
"text": "\`@value\` is a invalid syntax.",
},
{
"category": "error",
"code": 0,
"end": {
"line": 2,
"offset": 21,
},
"source": "css-modules-kit",
"start": {
"line": 2,
"offset": 8,
},
"text": "A \`:global(...)\` is not allowed inside of \`:local(...)\`.",
},
{
"category": "error",
"code": 0,
"end": {
"line": 3,
"offset": 7,
},
"source": "css-modules-kit",
"start": {
"line": 3,
"offset": 1,
},
"text": "css-modules-kit does not support \`:local\`. Use \`:local(...)\` instead.",
},
]
`);
});