-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
49 lines (37 loc) · 1.26 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
// import
var postcss = require('postcss');
var customUnits = require('./index.js');
// fns
function test(css, opts) {
return postcss(customUnits(opts)).process(css);
}
// run
describe('customUnits()', function () {
it('should not affect standard output', function () {
var css = 'body {margin: 1 1em 1px 1vh; font-family: sans-serif;}';
test(css).then(function (res) {
expect(res.css).to.equal(css);
});
});
it('should use custom unit in subsequent uses', function () {
var css = 'body {--unit-bl: 10px; width: 1bl;}';
var out = 'body {--unit-bl: 10px; width: 10px;}';
test(css).then(function (res) {
expect(res.css).to.equal(out);
});
});
it('should use handle floats properly', function () {
var css = 'body {--unit-bl: 100px; width: 1.5bl; height: 0.25bl;}';
var out = 'body {--unit-bl: 100px; width: 150px; height: 25px;}';
test(css).then(function (res) {
expect(res.css).to.equal(out);
});
});
it('should use allow reassignment', function () {
var css = 'body {--unit-bl: 1px; width: 1bl; --unit-bl: 2px; height: 1bl;}';
var out = 'body {--unit-bl: 1px; width: 1px; --unit-bl: 2px; height: 2px;}';
test(css).then(function (res) {
expect(res.css).to.equal(out);
});
});
});