|
| 1 | +import * as fs from 'node:fs/promises' |
1 | 2 | import { expect, test } from 'vitest'
|
2 | 3 | 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' |
4 | 6 |
|
5 | 7 | withFixture('basic', (c) => {
|
6 | 8 | function testFixture(fixture) {
|
@@ -383,3 +385,43 @@ withFixture('v4/basic', (c) => {
|
383 | 385 | ],
|
384 | 386 | })
|
385 | 387 | })
|
| 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