-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.js
executable file
·71 lines (60 loc) · 2.02 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
'use strict';
var postcss = require('postcss');
var colorGray = require('./');
var test = require('tape');
function useGray() {
return postcss().use(colorGray());
}
test('filterDeclarations()', function(t) {
t.plan(8);
t.equal(
useGray().process('a {color: gray(200); background: gray(00000034%)}').css,
'a {color: rgb(200, 200, 200); background: rgb(87, 87, 87)}',
'should convert gray(A) to rgb(A,A,A).'
);
t.equal(
useGray().process('a {color: gray( 1, 4.5%)}; b {color: gray(030%,0.75 \t)}').css,
'a {color: rgba(1, 1, 1, 0.045)}; b {color: rgba(77, 77, 77, 0.75)}',
'should convert gray(A,B) to rgba(A,A,A,B).'
);
t.equal(
useGray().process('a {border-color: gray;}').css,
'a {border-color: gray;}',
'should not modify original CSS when gray() is not used.'
);
t.throws(
function() {
return useGray().process('a {color: gray()}').css;
},
/Unable to parse color from string "gray\(\)"/,
'should throw an error when gray() doesn\'t take any arguments.'
);
t.throws(
function() {
return useGray().process('a {color: gray(,foo)}').css;
},
/<css input>:1:4: Unable to parse color from string "gray\(,foo\)"/,
'should throw an error when gray() args start with a comma.'
);
t.throws(
function() {
return useGray().process('a {color: gray(foo,)}').css;
},
/<css input>:1:4: Unable to parse color from string "gray\(foo,\)"/,
'should throw an error when gray() args end with a comma.'
);
t.throws(
function() {
return useGray().process('a {color: gray(red)}', {from: 'fixture.css'}).css;
},
/fixture\.css:1:4: Unable to parse color from string "gray\(red\)"/,
'should throw a detailed error when a source file is specified.'
);
t.throws(
function() {
return useGray().process('a {color: gray(,)}', {map: true}).css;
},
/<css input>:1:4: Unable to parse color from string "gray\(,\)"/,
'should throw a detailed error when source map is enabled but file isn\'t specified.'
);
});