10000 Add test for nested rules · tailwindlabs/tailwindcss@db8e06c · GitHub
Skip to content

Commit db8e06c

Browse files
committed
Add test for nested rules
1 parent 3be6a04 commit db8e06c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

__tests__/processPlugins.test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,61 @@ test('media queries can be defined multiple times using objects-in-array syntax'
451451
`)
452452
})
453453

454+
test('plugins can create nested rules', () => {
455+
const [components, utilities] = processPluginsWithValidConfig({
456+
plugins: [
457+
function({ addComponents }) {
458+
addComponents({
459+
'.btn-blue': {
460+
backgroundColor: 'blue',
461+
color: 'white',
462+
padding: '.5rem 1rem',
463+
borderRadius: '.25rem',
464+
'&:hover': {
465+
backgroundColor: 'darkblue',
466+
},
467+
'@media (min-width: 500px)': {
468+
'&:hover': {
469+
backgroundColor: 'orange',
470+
},
471+
},
472+
'> a': {
473+
color: 'red',
474+
},
475+
'h1 &': {
476+
color: 'purple',
477+
}
478+
},
479+
})
480+
},
481+
],
482+
})
483+
484+
expect(utilities.length).toBe(0)
485+
expect(css(components)).toMatchCss(`
486+
.btn-blue {
487+
background-color: blue;
488+
color: white;
489+
padding: .5rem 1rem;
490+
border-radius: .25rem;
491+
}
492+
.btn-blue:hover {
493+
background-color: darkblue;
494+
}
495+
@media (min-width: 500px) {
496+
.btn-blue:hover {
497+
background-color: orange;
498+
}
499+
}
500+
.btn-blue > a {
501+
color: red;
502+
}
503+
h1 .btn-blue {
504+
color: purple;
505+
}
506+
`)
507+
})
508+
454509
test('plugins can create rules with escaped selectors', () => {
455510
const config = {
456511
plugins: [

0 commit comments

Comments
 (0)