Skip to content

Commit 23b5639

Browse files
Copilotnzakas
andcommitted
Move slash notation tests to existing test files - address feedback from #3246846229
Co-authored-by: nzakas <[email protected]>
1 parent f91f33e commit 23b5639

File tree

3 files changed

+110
-108
lines changed

3 files changed

+110
-108
lines changed

tests/original-issue-fix.test.js

Lines changed: 0 additions & 108 deletions
This file was deleted.

tests/tailwind3.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,57 @@ describe("Tailwind 3", function () {
332332
]
333333
});
334334
});
335+
336+
it("should parse @apply with slash notation for opacity modifiers", () => {
337+
const testCases = [
338+
"a { @apply outline-ring/50; }",
339+
"a { @apply bg-blue-500/30; }",
340+
"a { @apply border-gray-200/50; }",
341+
];
342+
343+
testCases.forEach((testCase) => {
344+
assert.doesNotThrow(() => {
345+
const result = parse(testCase);
346+
assert.ok(result, `Should parse: ${testCase}`);
347+
}, `Should not throw parsing errors for: ${testCase}`);
348+
});
349+
});
350+
351+
it("should parse @apply with variants and slash notation", () => {
352+
const testCases = [
353+
"a { @apply hover:bg-blue-500/50; }",
354+
"a { @apply focus:outline-ring/30; }",
355+
"a { @apply active:border-red-500/25; }",
356+
];
357+
358+
testCases.forEach((testCase) => {
359+
assert.doesNotThrow(() => {
360+
const result = parse(testCase);
361+
assert.ok(result, `Should parse: ${testCase}`);
362+
}, `Should not throw parsing errors for: ${testCase}`);
363+
});
364+
});
365+
366+
it("should parse the original issue CSS without errors", () => {
367+
const originalCSS = `
368+
@layer base {
369+
* {
370+
@apply border-border outline-ring/50;
371+
}
372+
body {
373+
@apply bg-background text-foreground;
374+
}
375+
}
376+
`;
377+
378+
// The original issue was that this would throw:
379+
// "Parsing error: Semicolon or block is expected"
380+
// Now it should parse successfully
381+
assert.doesNotThrow(() => {
382+
const result = parse(originalCSS);
383+
assert.ok(result, "Should return a valid AST");
384+
}, "Should not throw parsing errors");
385+
});
335386
});
336387

337388
describe("Validation", () => {
@@ -340,6 +391,11 @@ describe("Tailwind 3", function () {
340391
"bg-blue-500",
341392
"hover:bg-blue-700",
342393
"focus:ring-blue-500",
394+
"outline-ring/50",
395+
"bg-blue-500/30",
396+
"border-gray-200/50",
397+
"hover:bg-blue-500/50",
398+
"focus:outline-ring/30",
343399
].forEach((value) => {
344400
it(`should validate type <tw-apply-ident> with ${value}`, () => {
345401
assert.strictEqual(lexer.matchType("tw-apply-ident", value).error, null);
@@ -354,6 +410,9 @@ describe("Tailwind 3", function () {
354410
"bg-blue-500",
355411
"hover:bg-blue-700",
356412
"bg-blue-500 focus:ring-blue-500",
413+
"outline-ring/50",
414+
"hover:bg-blue-500/50",
415+
"bg-blue-500/30 focus:outline-ring/50",
357416
].forEach((value) => {
358417
it(`should validate @apply ${value}`, () => {
359418
assert.strictEqual(lexer.matchAtrulePrelude("apply", value).error, null);

tests/tailwind4.test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,57 @@ describe("Tailwind 4", function () {
10181018
]
10191019
});
10201020
});
1021+
1022+
it("should parse @apply with slash notation for opacity modifiers", () => {
1023+
const testCases = [
1024+
"a { @apply outline-ring/50; }",
1025+
"a { @apply bg-blue-500/30; }",
1026+
"a { @apply border-gray-200/50; }",
1027+
];
1028+
1029+
testCases.forEach((testCase) => {
1030+
assert.doesNotThrow(() => {
1031+
const result = parse(testCase);
1032+
assert.ok(result, `Should parse: ${testCase}`);
1033+
}, `Should not throw parsing errors for: ${testCase}`);
1034+
});
1035+
});
1036+
1037+
it("should parse @apply with variants and slash notation", () => {
1038+
const testCases = [
1039+
"a { @apply hover:bg-blue-500/50; }",
1040+
"a { @apply focus:outline-ring/30; }",
1041+
"a { @apply active:border-red-500/25; }",
1042+
];
1043+
1044+
testCases.forEach((testCase) => {
1045+
assert.doesNotThrow(() => {
1046+
const result = parse(testCase);
1047+
assert.ok(result, `Should parse: ${testCase}`);
1048+
}, `Should not throw parsing errors for: ${testCase}`);
1049+
});
1050+
});
1051+
1052+
it("should parse the original issue CSS without errors", () => {
1053+
const originalCSS = `
1054+
@layer base {
1055+
* {
1056+
@apply border-border outline-ring/50;
1057+
}
1058+
body {
1059+
@apply bg-background text-foreground;
1060+
}
1061+
}
1062+
`;
1063+
1064+
// The original issue was that this would throw:
1065+
// "Parsing error: Semicolon or block is expected"
1066+
// Now it should parse successfully
1067+
assert.doesNotThrow(() => {
1068+
const result = parse(originalCSS);
1069+
assert.ok(result, "Should return a valid AST");
1070+
}, "Should not throw parsing errors");
1071+
});
10211072
});
10221073

10231074
describe("@reference", () => {

0 commit comments

Comments
 (0)