Skip to content

Commit eb2cc44

Browse files
committed
Add test
1 parent bb4bd75 commit eb2cc44

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import * as fs from 'node:fs/promises'
12
import { expect, test } from 'vitest'
23
import { withFixture } from '../common'
3-
import * as fs from 'node:fs/promises'
4+
import { css, defineTest } from '../../src/testing'
5+
import { createClient } from '../utils/client'
46

57
withFixture('basic', (c) => {
68
function testFixture(fixture) {
@@ -383,3 +385,43 @@ withFixture('v4/basic', (c) => {
383385
],
384386
})
385387
})
388+
389+
defineTest({
390+
name: 'Shows warning when using blocklisted classes',
391+
fs: {
392+
'app.css': css`
393+
@import 'tailwindcss';
394+
@source not inline("{,hover:}flex");
395+
`,
396+
},
397+
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
398+
handle: async ({ client }) => {
399+
let doc = await client.open({
400+
lang: 'html',
401+
text: '<div class="flex underline hover:flex">',
402+
})
403+
404+
let diagnostics = await doc.diagnostics()
405+
406+
expect(diagnostics).toEqual([
407+
{
408+
code: 'usedBlocklistedClass',
409+
message: 'The class "flex" will not be generated as it has been blocklisted',
410+
range: {
411+
start: { line: 0, character: 12 },
412+
end: { line: 0, character: 16 },
413+
},
414+
severity: 2,
415+
},
416+
{
417+
code: 'usedBlocklistedClass',
418+
message: 'The class "hover:flex" will not be generated as it has been blocklisted',
419+
range: {
420+
start: { line: 0, character: 27 },
421+
end: { line: 0, character: 37 },
422+
},
423+
severity: 2,
424+
},
425+
])
426+
},
427+
})

0 commit comments

Comments
 (0)