-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
75 lines (67 loc) · 2.37 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import postcss from 'postcss';
import test from 'ava';
import plugin from './';
function run(t, input, output, opts = { }) {
return postcss([ plugin(opts) ]).process(input)
.then( result => {
t.deepEqual(result.css, output);
t.deepEqual(result.warnings().length, 0);
});
}
test('compiles breakpoints shortcuts to @media rules', t => {
return run(
t,
'a {font-size:{ 0: 14px; 768: 16px; 1600: 19px; }}',
'a {font-size: 14px}@media screen and (min-width: 768px) ' +
'{a {font-size: 16px;}}@media screen and (min-width: 1600px) ' +
'{a {font-size: 19px;}}'
);
});
test('does not process commented responsive values', t => {
return run(
t,
'a {font-size: {0: 14px; /*768: 16px;*/ 1024: 18px;}}',
'a {font-size: 14px}@media screen and (min-width: 1024px)' +
' {a {font-size: 18px;}}'
);
});
test('does not change commented blocks output', t => {
return run(
t,
'/*a {font-size: { 0: 14px; 768: 16px; }}*/',
'/*a {font-size: { 0: 14px; 768: 16px; }}*/'
);
});
test('does not change properties with no breakpoint shortcuts', t => {
return run(
t,
'a {font-size:{ 0: 14px; 768: 16px; 1600: 19px; } color: red;}',
'a {font-size: 14px; color: red;}' +
'@media screen and (min-width: 768px) {a {font-size: 16px;}}' +
'@media screen and (min-width: 1600px) {a {font-size: 19px;}}'
);
});
test('compiles multiple properties', t => {
return run(
t,
'a {font-size:{ 0: 14px; 768: 16px; 1600: 19px; } ' +
'color:{ 0: red; 768: blue; 1600: green }}',
'a {font-size: 14px; color: red}' +
'@media screen and (min-width: 768px) ' +
'{a {font-size: 16px;color: blue;}}' +
'@media screen and (min-width: 1600px) ' +
'{a {font-size: 19px;color: green;}}'
);
});
test('compiles multiple selectors with breakpoint shortcuts', t => {
return run(
t,
'a {font-size:{ 0: 14px; 768: 16px; 1600: 19px; }} ' +
'p {font-size:{ 0: 12px; 768: 14px; 1600: 16px; }}',
'a {font-size: 14px} p {font-size: 12px} ' +
'@media screen and (min-width: 768px) ' +
'{a {font-size: 16px;}p {font-size: 14px;}} ' +
'@media screen and (min-width: 1600px) ' +
'{a {font-size: 19px;}p {font-size: 16px;}}'
);
});