Skip to content

Commit 2abeb95

Browse files
Add test for multiple selector names and pseudo classes/elements
1 parent e4a5e48 commit 2abeb95

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

packages/tailwindcss/src/plugin-api.test.ts

+77
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,83 @@ describe('addUtilities()', () => {
10111011
)
10121012
}).rejects.toThrowError(/invalid utility selector/)
10131013
})
1014+
1015+
test('supports multiple selector names', async () => {
1016+
let compiled = await compile(
1017+
css`
1018+
@plugin "my-plugin";
1019+
@tailwind utilities;
1020+
1021+
@theme reference {
1022+
--breakpoint-lg: 1024px;
1023+
}
1024+
`,
1025+
{
1026+
async loadPlugin() {
1027+
return ({ addUtilities }: PluginAPI) => {
1028+
addUtilities({
1029+
'.form-input, .form-textarea': {
1030+
appearance: 'none',
1031+
'background-color': '#fff',
1032+
},
1033+
})
1034+
}
1035+
},
1036+
},
1037+
)
1038+
1039+
expect(optimizeCss(compiled.build(['form-input', 'lg:form-textarea'])).trim())
1040+
.toMatchInlineSnapshot(`
1041+
".form-input {
1042+
appearance: none;
1043+
background-color: #fff;
1044+
}
1045+
1046+
@media (width >= 1024px) {
1047+
.lg\\:form-textarea {
1048+
appearance: none;
1049+
background-color: #fff;
1050+
}
1051+
}"
1052+
`)
1053+
})
1054+
1055+
test('supports pseudo classes and pseudo elements', async () => {
1056+
let compiled = await compile(
1057+
css`
1058+
@plugin "my-plugin";
1059+
@tailwind utilities;
1060+
1061+
@theme reference {
1062+
--breakpoint-lg: 1024px;
1063+
}
1064+
`,
1065+
{
1066+
async loadPlugin() {
1067+
return ({ addUtilities }: PluginAPI) => {
1068+
addUtilities({
1069+
'.form-input, .form-textarea:hover:focus': {
1070+
'background-color': 'red',
1071+
},
1072+
})
1073+
}
1074+
},
1075+
},
1076+
)
1077+
1078+
expect(optimizeCss(compiled.build(['form-input', 'lg:form-textarea'])).trim())
1079+
.toMatchInlineSnapshot(`
1080+
".form-input {
1081+
background-color: red;
1082+
}
1083+
1084+
@media (width >= 1024px) {
1085+
.lg\\:form-textarea:hover:focus {
1086+
background-color: red;
1087+
}
1088+
}"
1089+
`)
1090+
})
10141091
})
10151092

10161093
describe('matchUtilities()', () => {

0 commit comments

Comments
 (0)