-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
210 lines (178 loc) · 7.29 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import postcss from 'postcss';
import test from 'ava';
import fs from 'fs';
import plugin from './';
function run(t, input, output, opts = { }) {
return postcss([ plugin(opts) ]).process(input, { from: undefined })
.then( result => {
fs.writeFileSync('test/out.css', result.css);
t.deepEqual(result.css, output);
t.deepEqual(result.warnings().length, 0);
});
}
function runWithWarn(t, input, output, numberOfWarn, opts = { }) {
return postcss([ plugin(opts) ]).process(input, { from: undefined })
.then( result => {
t.deepEqual(result.css, output);
t.deepEqual(result.warnings().length, numberOfWarn);
});
}
test('truncate multiline', t => {
return run(t, 'a{ @util truncate (3, 1.5); }',
'a{ display: block; display: -webkit-box;' +
' height: 4.5em; line-height: 1.5;' +
' -webkit-line-clamp: 3; -webkit-box-orient: vertical;' +
' overflow: hidden; text-overflow: ellipsis; }', { });
});
test('truncate multiline 2', t => {
return run(t, 'a{ @util truncate(3, 1.5); }',
'a{ display: block; display: -webkit-box;' +
' height: 4.5em; line-height: 1.5; -webkit-line-clamp: 3;' +
' -webkit-box-orient: vertical; overflow: hidden;' +
' text-overflow: ellipsis; }', { });
});
test('truncate multiline 3', t => {
return run(t, 'a{ @util truncate(3 1.5); }',
'a{ display: block; display: -webkit-box; height: 4.5em;' +
' line-height: 1.5; -webkit-line-clamp: 3;' +
' -webkit-box-orient: vertical; overflow: hidden;' +
' text-overflow: ellipsis; }', { });
});
test('truncate', t => {
return run(t, 'a{ @util truncate; }',
'a{ white-space: nowrap; overflow: hidden;' +
' text-overflow: ellipsis; }', { });
});
test('reset list', t => {
return run(t, 'ul{ @util reset-list; }',
'ul{ margin-top: 0; margin-bottom: 0; padding-left: 0; }' +
'ul li{ list-style: none; }', { });
});
test('hide visually', t => {
return run(t, 'a{ @util hide-visually; }',
'a{ border: 0; clip: rect(0 0 0 0); height: 1px;' +
' margin: -1px; overflow: hidden; padding: 0;' +
' position: absolute; width: 1px; }', { });
});
test('clearfix', t => {
return run(t, 'a{ @util clearfix; }',
'a:after{\n content: \'\';\n ' +
'display: block;\n clear: both;\n ' +
'visibility: hidden; }', { });
});
test('text hide', t => {
return run(t, 'a{ background: #000; color: #fff; @util text-hide; }',
'a{ background: #000; color: #fff; font: 0/0 a;' +
' color: transparent; text-shadow: none;' +
' background-color: transparent; border: 0; }', {
textHideMethod: 'font'
});
});
test('text hide default', t => {
var input = fs.readFileSync('test/text-hide.css', 'utf8');
var output = fs.readFileSync('test/text-hide.expect.css', 'utf8');
return run(t, input, output, { });
});
test('triangle', t => {
var input = fs.readFileSync('test/triangle.css', 'utf8');
var output = fs.readFileSync('test/triangle.expect.css', 'utf8');
return run(t, input, output, { });
});
test('hd breakpoint', t => {
var input = fs.readFileSync('test/hd.css', 'utf8');
var output = fs.readFileSync('test/hd.expect.css', 'utf8');
return run(t, input, output, { });
});
test('warnings', t => {
var input = fs.readFileSync('test/warnings.css', 'utf8');
var output = fs.readFileSync('test/warnings.expect.css', 'utf8');
return runWithWarn(t, input, output, 2, { });
});
test('with nested rules', t => {
var input = fs.readFileSync('test/nested.css', 'utf8');
var output = fs.readFileSync('test/nested.expect.css', 'utf8');
return run(t, input, output, { });
});
test('with nested rules and options', t => {
var input = fs.readFileSync('test/nested-options.css', 'utf8');
var output = fs.readFileSync('test/nested-options.expect.css', 'utf8');
return run(t, input, output, {
noHoverSelector: '.noHover',
noJsSelector: '.noJS'
});
});
test('clearfix ie8', t => {
var input = fs.readFileSync('test/clearfix-ie8.css', 'utf8');
var output = fs.readFileSync('test/clearfix-ie8.expect.css', 'utf8');
return run(t, input, output, { ie8: true });
});
test('var support', t => {
var input = fs.readFileSync('test/vars.css', 'utf8');
var output = fs.readFileSync('test/vars.expect.css', 'utf8');
return run(t, input, output, {});
});
test('word wrap', t => {
var input = fs.readFileSync('test/word-wrap.css', 'utf8');
var output = fs.readFileSync('test/word-wrap.expect.css', 'utf8');
return run(t, input, output, {});
});
test('size', t => {
var input = fs.readFileSync('test/size.css', 'utf8');
var output = fs.readFileSync('test/size.expect.css', 'utf8');
return run(t, input, output, {});
});
test('sticky footer', t => {
var input = fs.readFileSync('test/sticky-footer.css', 'utf8');
var output = fs.readFileSync('test/sticky-footer.expect.css', 'utf8');
return run(t, input, output, {});
});
test('reset text', t => {
var input = fs.readFileSync('test/reset-text.css', 'utf8');
var output = fs.readFileSync('test/reset-text.expect.css', 'utf8');
return run(t, input, output, {});
});
test('border color', t => {
var input = fs.readFileSync('test/border-color.css', 'utf8');
var output = fs.readFileSync('test/border-color.expect.css', 'utf8');
return run(t, input, output, { });
});
test('border style', t => {
var input = fs.readFileSync('test/border-style.css', 'utf8');
var output = fs.readFileSync('test/border-style.expect.css', 'utf8');
return run(t, input, output, { });
});
test('border width', t => {
var input = fs.readFileSync('test/border-width.css', 'utf8');
var output = fs.readFileSync('test/border-width.expect.css', 'utf8');
return run(t, input, output, { });
});
test('padding', t => {
var input = fs.readFileSync('test/padding.css', 'utf8');
var output = fs.readFileSync('test/padding.expect.css', 'utf8');
return run(t, input, output, { });
});
test('margin', t => {
var input = fs.readFileSync('test/margin.css', 'utf8');
var output = fs.readFileSync('test/margin.expect.css', 'utf8');
return run(t, input, output, { });
});
test('border radius', t => {
var input = fs.readFileSync('test/border-radius.css', 'utf8');
var output = fs.readFileSync('test/border-radius.expect.css', 'utf8');
return run(t, input, output, { });
});
test('position', t => {
var input = fs.readFileSync('test/position.css', 'utf8');
var output = fs.readFileSync('test/position.expect.css', 'utf8');
return run(t, input, output, { });
});
test('text-stroke', t => {
var input = fs.readFileSync('test/text-stroke.css', 'utf8');
var output = fs.readFileSync('test/text-stroke.expect.css', 'utf8');
return run(t, input, output, { });
});
test('all', t => {
var input = fs.readFileSync('test/test.css', 'utf8');
var output = fs.readFileSync('test/test.expect.css', 'utf8');
return run(t, input, output, { });
});