forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplyAtRule.test.js
53 lines (43 loc) · 1.2 KB
/
applyAtRule.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import postcss from 'postcss'
import plugin from '../src/lib/substituteClassApplyAtRules'
function run(input, opts) {
return postcss([plugin(opts)]).process(input)
}
test("it copies a class's declarations into itself", () => {
const output = '.a { color: red; } .b { color: red; }'
return run('.a { color: red; } .b { @apply .a; }', {}).then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})
})
test("it doesn't copy a media query definition into itself", () => {
const output = `.a {
color: red;
}
@media (min-width: 300px) {
.a { color: blue; }
}
.b {
color: red;
}`
return run(
`.a {
color: red;
}
@media (min-width: 300px) {
.a { color: blue; }
}
.b {
@apply .a;
}`,
{}
).then(result => {
expect(result.css).toEqual(output)
expect(result.warnings().length).toBe(0)
})
})
test('it fails if the class does not exist', () => {
run('.b { @apply .a; }', {}).catch(error => {
expect(error.reason).toEqual('No .a class found.')
})
})