Skip to content

Commit c69e1f9

Browse files
committed
add failing test
1 parent a08cb3d commit c69e1f9

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

integrations/upgrade/js-config.test.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,95 @@ test(
11221122
},
11231123
)
11241124

1125+
test(
1126+
'migrate supports theme keys to custom variants',
1127+
{
1128+
fs: {
1129+
'package.json': json`
1130+
{
1131+
"dependencies": {
1132+
"tailwindcss": "^3",
1133+
"@tailwindcss/upgrade": "workspace:^"
1134+
}
1135+
}
1136+
`,
1137+
'tailwind.config.ts': ts`
1138+
export default {
1139+
content: {
1140+
relative: true,
1141+
files: ['./src/**/*.html'],
1142+
},
1143+
theme: {
1144+
extend: {
1145+
supports: {
1146+
// Automatically handled by bare values (using CSS variable as the value)
1147+
foo: 'foo: var(--foo)', // parentheses are optional
1148+
bar: '(bar: var(--bar))',
1149+
1150+
// Not automatically handled by bare values because names differ
1151+
foo: 'bar: var(--foo)', // parentheses are optional
1152+
bar: '(qux: var(--bar))',
1153+
1154+
// Custom
1155+
grid: 'display: grid',
1156+
},
1157+
},
1158+
},
1159+
}
1160+
`,
1161+
'src/input.css': css`
1162+
@tailwind base;
1163+
@tailwind components;
1164+
@tailwind utilities;
1165+
`,
1166+
},
1167+
},
1168+
async ({ exec, fs, expect }) => {
1169+
await exec('npx @tailwindcss/upgrade')
1170+
1171+
expect(await fs.dumpFiles('src/*.css')).toMatchInlineSnapshot(`
1172+
"
1173+
--- src/input.css ---
1174+
@import 'tailwindcss';
1175+
1176+
@custom-variant supports-foo {
1177+
@supports (bar: var(--foo)) {
1178+
@slot;
1179+
}
1180+
}
1181+
@custom-variant supports-bar {
1182+
@supports ((qux: var(--bar))) {
1183+
@slot;
1184+
}
1185+
}
1186+
@custom-variant supports-grid {
1187+
@supports (display: grid) {
1188+
@slot;
1189+
}
1190+
}
1191+
1192+
/*
1193+
The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
1194+
so we've added these compatibility styles to make sure everything still
1195+
looks the same as it did with Tailwind CSS v3.
1196+
1197+
If we ever want to remove these styles, we need to add an explicit border
1198+
color utility to any element that depends on these defaults.
1199+
*/
1200+
@layer base {
1201+
*,
1202+
::after,
1203+
::before,
1204+
::backdrop,
1205+
::file-selector-button {
1206+
border-color: var(--color-gray-200, currentcolor);
1207+
}
1208+
}
1209+
"
1210+
`)
1211+
},
1212+
)
1213+
11251214
describe('border compatibility', () => {
11261215
test(
11271216
'migrate border compatibility',

0 commit comments

Comments
 (0)