2017-10-21 11:26:30 -04:00
|
|
|
import postcss from 'postcss'
|
|
|
|
|
import plugin from '../src/lib/substituteHoverableAtRules'
|
|
|
|
|
|
2017-11-03 10:04:48 -04:00
|
|
|
function run(input, opts = () => {}) {
|
2017-10-21 11:26:30 -04:00
|
|
|
return postcss([plugin(opts)]).process(input)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-04 00:35:59 -05:00
|
|
|
test('it adds a hoverable variant to each nested class definition', () => {
|
2017-10-21 11:26:30 -04:00
|
|
|
const input = `
|
|
|
|
|
@hoverable {
|
|
|
|
|
.banana { color: yellow; }
|
|
|
|
|
.chocolate { color: brown; }
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const output = `
|
2017-11-22 15:54:25 -05:00
|
|
|
.banana { color: yellow; }
|
|
|
|
|
.chocolate { color: brown; }
|
|
|
|
|
.hover\\:banana:hover { color: yellow; }
|
|
|
|
|
.hover\\:chocolate:hover { color: brown; }
|
2017-10-21 11:26:30 -04:00
|
|
|
`
|
|
|
|
|
|
2017-11-03 10:04:48 -04:00
|
|
|
return run(input).then(result => {
|
2017-11-22 15:54:25 -05:00
|
|
|
expect(result.css).toMatchCss(output)
|
2017-10-21 11:26:30 -04:00
|
|
|
expect(result.warnings().length).toBe(0)
|
|
|
|
|
})
|
|
|
|
|
})
|