Skip to content

Commit 7c9a0ce

Browse files
committed
add failing test
1 parent 0e1549a commit 7c9a0ce

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

integrations/upgrade/js-config.test.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,102 @@ test(
11361136
},
11371137
)
11381138

1139+
test(
1140+
'migrate supports theme keys to custom variants',
1141+
{
1142+
fs: {
1143+
'package.json': json`
1144+
{
1145+
"dependencies": {
1146+
"tailwindcss": "^3",
1147+
"@tailwindcss/upgrade": "workspace:^"
1148+
}
1149+
}
1150+
`,
1151+
'tailwind.config.ts': ts`
1152+
export default {
1153+
content: {
1154+
relative: true,
1155+
files: ['./src/**/*.html'],
1156+
},
1157+
theme: {
1158+
extend: {
1159+
supports: {
1160+
// Automatically handled by bare values (using CSS variable as the value)
1161+
foo: 'foo: var(--foo)', // parentheses are optional
1162+
bar: '(bar: var(--bar))',
1163+
1164+
// Not automatically handled by bare values because names differ
1165+
foo: 'bar: var(--foo)', // parentheses are optional
1166+
bar: '(qux: var(--bar))',
1167+
1168+
// Custom
1169+
grid: 'display: grid',
1170+
},
1171+
},
1172+
},
1173+
}
1174+
`,
1175+
'src/input.css': css`
1176+
@tailwind base;
1177+
@tailwind components;
1178+
@tailwind utilities;
1179+
`,
1180+
},
1181+
},
1182+
async ({ exec, fs, expect }) => {
1183+
await exec('npx @tailwindcss/upgrade')
1184+
1185+
expect(await fs.dumpFiles('src/*.css')).toMatchInlineSnapshot(`
1186+
"
1187+
--- src/input.css ---
1188+
@import 'tailwindcss';
1189+
1190+
/*
1191+
These variants have been migrated from your Tailwind CSS configuration file.
1192+
Since they are custom variants, they will be sorted after all built-in variants.
1193+
1194+
This may result in elements appearing different if you were relying on the order of
1195+
the variants in the CSS.
1196+
*/
1197+
@custom-variant supports-foo {
1198+
@supports (bar: var(--foo)) {
1199+
@slot;
1200+
}
1201+
}
1202+
@custom-variant supports-bar {
1203+
@supports ((qux: var(--bar))) {
1204+
@slot;
1205+
}
1206+
}
1207+
@custom-variant supports-grid {
1208+
@supports (display: grid) {
1209+
@slot;
1210+
}
1211+
}
1212+
1213+
/*
1214+
The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
1215+
so we've added these compatibility styles to make sure everything still
1216+
looks the same as it did with Tailwind CSS v3.
1217+
1218+
If we ever want to remove these styles, we need to add an explicit border
1219+
color utility to any element that depends on these defaults.
1220+
*/
1221+
@layer base {
1222+
*,
1223+
::after,
1224+
::before,
1225+
::backdrop,
1226+
::file-selector-button {
1227+
border-color: var(--color-gray-200, currentcolor);
1228+
}
1229+
}
1230+
"
1231+
`)
1232+
},
1233+
)
1234+
11391235
describe('border compatibility', () => {
11401236
test(
11411237
'migrate border compatibility',

0 commit comments

Comments
 (0)