Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit d783bae

Browse files
author
Jed Mao
committed
Test browsers option
1 parent 467156c commit d783bae

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/__tests__/option.browsers.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import tape from "tape"
2+
3+
import cssnext from ".."
4+
5+
tape("cssnext browsers option", function(t) {
6+
7+
// no recent browser need pixrem
8+
const remInput = "body{font-size:2rem}"
9+
t.equal(
10+
cssnext({ browsers: "last 1 version" }).process(remInput).css,
11+
remInput,
12+
"should not enable px fallback when all browsers support it"
13+
)
14+
15+
const customPropsInput = ":root{--foo:bar}baz{qux:var(--foo)}"
16+
const customPropsOutput = "baz{qux: bar}"
17+
18+
// fx 30 doesn't handle custom prop
19+
t.equal(
20+
cssnext({ browsers: "Firefox >= 30" }).process(customPropsInput).css,
21+
customPropsOutput,
22+
"should enable custom properties when browsers do not support it"
23+
)
24+
25+
// fx 31 handle custom prop
26+
t.equal(
27+
cssnext({ browsers: "Firefox >= 31" }).process(customPropsInput).css,
28+
customPropsInput,
29+
"should NOT enable custom properties when browsers support it"
30+
)
31+
32+
// fx 31 support but not IE 8
33+
t.equal(
34+
cssnext({ browsers: "Firefox >= 31, IE 8" }).process(customPropsInput).css,
35+
customPropsOutput,
36+
"should enable custom properties when at least one browsers do not " +
37+
"support it"
38+
)
39+
40+
t.end()
41+
})
42+
43+
tape("cssnext browsers option propagation", function(t) {
44+
const input = "body{transition: 1s}"
45+
const output = "body{-webkit-transition: 1s;transition: 1s}"
46+
47+
// Safari 6 need -webkit prefix
48+
t.equal(
49+
cssnext({ browsers: "Safari 6" }).process(input).css,
50+
output,
51+
"should propagate browsers option to autoprefixer"
52+
)
53+
54+
// Safari 6.1 do not need -webkit prefix
55+
t.equal(
56+
cssnext({ browsers: "Safari 6.1" }).process(input).css,
57+
input,
58+
"should propagate browsers option to autoprefixer"
59+
)
60+
61+
t.end()
62+
})

0 commit comments

Comments
 (0)