Skip to content

Commit 536460b

Browse files
committed
add failing test
1 parent 4fe4301 commit 536460b

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
@@ -1044,6 +1044,80 @@ test(
10441044
},
10451045
)
10461046

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

0 commit comments

Comments
 (0)