-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
84 lines (75 loc) · 1.82 KB
/
index.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
const _ = require('lodash');
const postcss = require('postcss');
const SEProperties = require('swedish-css-properties');
const SEValues = require('swedish-css-values');
const plugin = require('./');
const test = (input, output, opts, done) => {
postcss([plugin(opts)])
.process(input, { from: undefined })
.then((result) => {
expect(result.css).toEqual(output);
expect(result.warnings()).toStrictEqual([]);
done();
})
.catch((error) => {
done(error);
});
};
const swedishPropertiesTest = (swedish, english, value) => {
it(`converts ${swedish} to ${english}`, (done) => {
test(`a{${swedish}: ${value};}`, `a{${english}: ${value};}`, {}, done);
});
};
const swedishValuesTest = (swedish, english, property) => {
it(`converts ${english} to ${swedish}`, (done) => {
test(
`a{${property}: ${swedish};}`,
`a{${property}: ${english};}`,
{},
done
);
});
};
describe('postcss-swedish-stylesheets', () => {
// Test Properties
_.forEach(SEProperties, (value, key) => {
swedishPropertiesTest(value, key, '10px');
});
// Test Values
_.forEach(SEValues, (value, key) => {
swedishValuesTest(value, key, 'color');
});
// Test important
it('converts !viktigt to !important', (done) => {
test(
'a{ color: white !viktigt; }',
'a{ color: white !important; }',
{},
done
);
});
it('custom properties', (done) => {
test(
'a{ kulör: white !viktigt; }',
'a{ color: white !important; }',
{
properties: {
color: 'kulör',
},
},
done
);
});
it('custom values', (done) => {
test(
'a{ color: supervit !viktigt; }',
'a{ color: white !important; }',
{
values: {
white: 'supervit',
},
},
done
);
});
});