Skip to content

Commit fb802e5

Browse files
committed
Add test
1 parent 89eeb17 commit fb802e5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,35 @@ withFixture('basic', (c) => {
119119
})
120120
})
121121
})
122+
123+
withFixture('overrides-variants', (c) => {
124+
async function completion({
125+
lang,
126+
text,
127+
position,
128+
context = {
129+
triggerKind: 1,
130+
},
131+
settings,
132+
}) {
133+
let textDocument = await c.openDocument({ text, lang, settings })
134+
135+
return c.sendRequest('textDocument/completion', {
136+
textDocument,
137+
position,
138+
context,
139+
})
140+
}
141+
142+
test.concurrent(
143+
'duplicate variant + value pairs do not produce multiple completions',
144+
async () => {
145+
let result = await completion({
146+
text: '<div class="custom-hover"></div>',
147+
position: { line: 0, character: 23 },
148+
})
149+
150+
expect(result.items.filter((item) => item.label.endsWith('custom-hover:')).length).toBe(1)
151+
}
152+
)
153+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
plugins: [
3+
function ({ addVariant, matchVariant }) {
4+
matchVariant('custom', (value) => `.custom:${value} &`, { values: { hover: 'hover' } })
5+
addVariant('custom-hover', `.custom:hover &:hover`)
6+
},
7+
],
8+
}

0 commit comments

Comments
 (0)