From c989134554728bbc543f1e3ef670ab957a8d09b1 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Sat, 21 Oct 2017 11:26:30 -0400 Subject: [PATCH] Add basic test for hoverable at-rule --- __tests__/hoverableAtRule.test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 __tests__/hoverableAtRule.test.js diff --git a/__tests__/hoverableAtRule.test.js b/__tests__/hoverableAtRule.test.js new file mode 100644 index 000000000..cd6747bd8 --- /dev/null +++ b/__tests__/hoverableAtRule.test.js @@ -0,0 +1,25 @@ +import postcss from 'postcss' +import plugin from '../src/lib/substituteHoverableAtRules' + +function run(input, opts = {}) { + return postcss([plugin(opts)]).process(input) +} + +test("it adds a hoverable variant to each nested class definition", () => { + const input = ` + @hoverable { + .banana { color: yellow; } + .chocolate { color: brown; } + } + ` + + const output = ` + .banana, .hover\\:banana:hover { color: yellow; } + .chocolate, .hover\\:chocolate:hover { color: brown; } + ` + + return run(input, {}).then(result => { + expect(result.css).toEqual(output) + expect(result.warnings().length).toBe(0) + }) +})