This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
96 lines (81 loc) · 2.47 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import postcss from 'postcss';
import test from 'ava';
import plugin from './';
import properties from './dictionary/properties';
import values from './dictionary/values';
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);
});
}
function propertyTest(italian, english) {
test(`Converts property "${italian}" to "${english}"`, t => {
return run(
t,
`a{ ${italian}: test }`,
`a{ ${english}: test }`
);
});
}
function valueTest(italian, english) {
test(`Converts value "${italian}" to "${english}"`, t => {
return run(
t,
`a{ test: ${italian} }`,
`a{ test: ${english} }`
);
});
}
// Tests
Object.keys(properties).forEach(
engProperty => {
const itaProperty = properties[engProperty];
if (typeof itaProperty === 'string') {
propertyTest(itaProperty, engProperty);
test('Equal properties should be commented out', t => {
t.notDeepEqual(itaProperty, engProperty);
});
} else {
for (let i = 0; i < itaProperty.length; i++) {
propertyTest(itaProperty[i], engProperty);
test('Equal properties should be commented out', t => {
t.notDeepEqual(itaProperty[i], engProperty);
});
}
}
}
);
Object.keys(values).forEach(
engValue => {
const itaValue = values[engValue];
if (typeof itaValue === 'string') {
valueTest(itaValue, engValue);
test('Equal values should be commented out', t => {
t.notDeepEqual(itaValue, engValue);
});
} else {
for (let i = 0; i < itaValue.length; i++) {
valueTest(itaValue[i], engValue);
test('Equal values should be commented out', t => {
t.notDeepEqual(itaValue[i], engValue);
});
}
}
}
);
test('Converts multiple values', t => {
return run(
t,
'a{ bordo-colore: neve blu blu blu; }',
'a{ border-color: snow blue blue blue; }'
);
});
test('Converts "!importante" to "!important"', t => {
return run(
t,
'a{ flex: 1 !importante; }',
'a{ flex: 1 !important; }'
);
});