Skip to content

Commit 6862fdd

Browse files
committed
Add @config completion tests for v4
1 parent 5017e99 commit 6862fdd

File tree

6 files changed

+117
-0
lines changed

6 files changed

+117
-0
lines changed

packages/tailwindcss-language-server/tests/completions/at-config.test.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,85 @@ withFixture('dependencies', (c) => {
8282
})
8383
})
8484
})
85+
86+
withFixture('v4/dependencies', (c) => {
87+
async function completion({
88+
lang,
89+
text,
90+
position,
91+
context = {
92+
triggerKind: 1,
93+
},
94+
settings,
95+
}) {
96+
let textDocument = await c.openDocument({ text, lang, settings })
97+
98+
return c.sendRequest('textDocument/completion', {
99+
textDocument,
100+
position,
101+
context,
102+
})
103+
}
104+
105+
test.concurrent('@config', async ({ expect }) => {
106+
let result = await completion({
107+
text: '@config "',
108+
lang: 'css',
109+
position: {
110+
line: 0,
111+
character: 9,
112+
},
113+
})
114+
115+
expect(result).toEqual({
116+
isIncomplete: false,
117+
items: [
118+
{
119+
label: 'sub-dir/',
120+
kind: 19,
121+
command: { command: 'editor.action.triggerSuggest', title: '' },
122+
data: expect.anything(),
123+
textEdit: {
124+
newText: 'sub-dir/',
125+
range: { start: { line: 0, character: 9 }, end: { line: 0, character: 9 } },
126+
},
127+
},
128+
{
129+
label: 'tailwind.config.js',
130+
kind: 17,
131+
data: expect.anything(),
132+
textEdit: {
133+
newText: 'tailwind.config.js',
134+
range: { start: { line: 0, character: 9 }, end: { line: 0, character: 9 } },
135+
},
136+
},
137+
],
138+
})
139+
})
140+
141+
test.concurrent('@config directory', async ({ expect }) => {
142+
let result = await completion({
143+
text: '@config "./sub-dir/',
144+
lang: 'css',
145+
position: {
146+
line: 0,
147+
character: 19,
148+
},
149+
})
150+
151+
expect(result).toEqual({
152+
isIncomplete: false,
153+
items: [
154+
{
155+
label: 'colors.js',
156+
kind: 17,
157+
data: expect.anything(),
158+
textEdit: {
159+
newText: 'colors.js',
160+
range: { start: { line: 0, character: 19 }, end: { line: 0, character: 19 } },
161+
},
162+
},
163+
],
164+
})
165+
})
166+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import 'tailwindcss';

packages/tailwindcss-language-server/tests/fixtures/v4/dependencies/package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"tailwindcss": "^4.0.0-alpha.21"
4+
}
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
foo: 'red',
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const colors = require('./sub-dir/colors')
2+
3+
module.exports = {
4+
theme: {
5+
extend: {
6+
colors,
7+
},
8+
},
9+
}

0 commit comments

Comments
 (0)