Skip to content

Commit 5e02dae

Browse files
committed
Add test
1 parent 00e647b commit 5e02dae

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { test, expect } from 'vitest'
22
import { withFixture } from '../common'
33
import { css, defineTest, html, js } from '../../src/testing'
44
import { createClient } from '../utils/client'
5+
import { CompletionItemKind } from 'vscode-languageserver'
56

67
function buildCompletion(c) {
78
return async function completion({
@@ -798,3 +799,53 @@ defineTest({
798799
expect(completion?.items.length).toBe(12289)
799800
},
800801
})
802+
803+
defineTest({
804+
name: 'v4: Theme key completions show in var(…)',
805+
fs: {
806+
'app.css': css`
807+
@import 'tailwindcss';
808+
809+
@theme {
810+
--color-custom: #000;
811+
}
812+
`,
813+
},
814+
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
815+
handle: async ({ client }) => {
816+
let document = await client.open({
817+
settings: {
818+
tailwindCSS: {
819+
classFunctions: ['clsx'],
820+
},
821+
},
822+
lang: 'css',
823+
text: css`
824+
.foo {
825+
color: var();
826+
}
827+
`,
828+
})
829+
830+
// color: var();
831+
// ^
832+
let completion = await document.completions({ line: 1, character: 13 })
833+
834+
expect(completion).toEqual({
835+
isIncomplete: false,
836+
items: expect.arrayContaining([
837+
// From the default theme
838+
expect.objectContaining({ label: '--font-sans' }),
839+
840+
// From the `@theme` block in the CSS file
841+
expect.objectContaining({
842+
label: '--color-custom',
843+
844+
// And it's shown as a color
845+
kind: CompletionItemKind.Color,
846+
documentation: '#000000',
847+
}),
848+
]),
849+
})
850+
},
851+
})

0 commit comments

Comments
 (0)