Skip to content

Commit 86283c9

Browse files
committed
add failing test
1 parent ebfee41 commit 86283c9

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

integrations/upgrade/js-config.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,80 @@ test(
10481048
},
10491049
)
10501050

1051+
test(
1052+
'migrate data theme keys to custom variants',
1053+
{
1054+
fs: {
1055+
'package.json': json`
1056+
{
1057+
"dependencies": {
1058+
"tailwindcss": "^3",
1059+
"@tailwindcss/upgrade": "workspace:^"
1060+
}
1061+
}
1062+
`,
1063+
'tailwind.config.ts': ts`
1064+
export default {
1065+
content: {
1066+
relative: true,
1067+
files: ['./src/**/*.html'],
1068+
},
1069+
theme: {
1070+
extend: {
1071+
data: {
1072+
// Automatically handled by bare values
1073+
foo: 'foo',
1074+
1075+
// Not automatically handled by bare values because names differ
1076+
bar: 'baz',
1077+
1078+
// Custom
1079+
checked: 'ui~="checked"',
1080+
},
1081+
},
1082+
},
1083+
}
1084+
`,
1085+
'src/input.css': css`
1086+
@tailwind base;
1087+
@tailwind components;
1088+
@tailwind utilities;
1089+
`,
1090+
},
1091+
},
1092+
async ({ exec, fs, expect }) => {
1093+
await exec('npx @tailwindcss/upgrade')
1094+
1095+
expect(await fs.dumpFiles('src/*.css')).toMatchInlineSnapshot(`
1096+
"
1097+
--- src/input.css ---
1098+
@import 'tailwindcss';
1099+
1100+
@custom-variant data-bar (&[data-baz]);
1101+
@custom-variant data-checked (&[data-ui~="checked"]);
1102+
1103+
/*
1104+
The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
1105+
so we've added these compatibility styles to make sure everything still
1106+
looks the same as it did with Tailwind CSS v3.
1107+
1108+
If we ever want to remove these styles, we need to add an explicit border
1109+
color utility to any element that depends on these defaults.
1110+
*/
1111+
@layer base {
1112+
*,
1113+
::after,
1114+
::before,
1115+
::backdrop,
1116+
::file-selector-button {
1117+
border-color: var(--color-gray-200, currentcolor);
1118+
}
1119+
}
1120+
"
1121+
`)
1122+
},
1123+
)
1124+
10511125
describe('border compatibility', () => {
10521126
test(
10531127
'migrate border compatibility',

0 commit comments

Comments
 (0)