Skip to content

Commit

Permalink
Add test for nested rules
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 7, 2018
1 parent 3be6a04 commit db8e06c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions __tests__/processPlugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,61 @@ test('media queries can be defined multiple times using objects-in-array syntax'
`)
})

test('plugins can create nested rules', () => {
const [components, utilities] = processPluginsWithValidConfig({
plugins: [
function({ addComponents }) {
addComponents({
'.btn-blue': {
backgroundColor: 'blue',
color: 'white',
padding: '.5rem 1rem',
borderRadius: '.25rem',
'&:hover': {
backgroundColor: 'darkblue',
},
'@media (min-width: 500px)': {
'&:hover': {
backgroundColor: 'orange',
},
},
'> a': {
color: 'red',
},
'h1 &': {
color: 'purple',
}
},
})
},
],
})

expect(utilities.length).toBe(0)
expect(css(components)).toMatchCss(`
.btn-blue {
background-color: blue;
color: white;
padding: .5rem 1rem;
border-radius: .25rem;
}
.btn-blue:hover {
background-color: darkblue;
}
@media (min-width: 500px) {
.btn-blue:hover {
background-color: orange;
}
}
.btn-blue > a {
color: red;
}
h1 .btn-blue {
color: purple;
}
`)
})

test('plugins can create rules with escaped selectors', () => {
const config = {
plugins: [
Expand Down

0 comments on commit db8e06c

Please sign in to comment.