forked from dotless/dotless
/
CssFixture.cs
363 lines (315 loc) · 6.52 KB
/
CssFixture.cs
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
namespace dotless.Test.Specs
{
using NUnit.Framework;
public class CssFixture : SpecFixtureBase
{
[Test]
public void CharsetDirective()
{
var input = "@charset \"utf-8\";";
AssertLessUnchanged(input);
}
[Test]
public void Directives()
{
var input =
@"
@media print {
font-size: 3em;
}
@media screen {
font-size: 10px;
}
@font-face {
font-family: 'Garamond Pro';
src: url(""/fonts/garamond-pro.ttf"");
}
";
AssertLessUnchanged(input);
}
[Test]
public void TagSelector()
{
var input = @"
div {
color: black;
}
div {
width: 99%;
}
";
AssertLessUnchanged(input);
}
[Test]
public void GlobalSelector()
{
var input = @"
* {
min-width: 45em;
}
";
AssertLessUnchanged(input);
}
[Test]
public void ChildSelector()
{
var input = @"
h1, h2 > a > p, h3 {
color: none;
}
";
AssertLessUnchanged(input);
}
[Test]
public void ClassAndIdSelectors()
{
var input =
@"
div.class {
color: blue;
}
div#id {
color: green;
}
.class#id {
color: purple;
}
.one.two.three {
color: grey;
}
";
AssertLessUnchanged(input);
}
[Test]
public void PseudoClass()
{
var input = @"
a:hover, a:link {
color: #999;
}
";
AssertLessUnchanged(input);
}
[Test]
public void FirstChildPseudoClass()
{
var input = @"
p, p:first-child {
text-transform: none;
}
";
AssertLessUnchanged(input);
}
[Test]
public void LangPseudoClass()
{
var input = @"
q:lang(no) {
quotes: none;
}
";
AssertLessUnchanged(input);
}
[Test]
public void NextSiblingSelector()
{
var input = @"
p + h1 {
font-size: 2.2em;
}
";
AssertLessUnchanged(input);
}
[Test]
public void PropertyWithNumbers()
{
var input = @"
textarea {
scrollbar-3dlight-color: yellow;
}
";
AssertLessUnchanged(input);
}
[Test]
public void PropertyWithUnderscore()
{
var input = @"
p {
color: red;
_color: yellow;
}
";
AssertLessUnchanged(input);
}
[Test]
public void Shorthands()
{
var input =
@"
#shorthands {
border: 1px solid #000;
font: 12px/16px Arial;
margin: 1px 0;
padding: 0 auto;
background: url(""http://www.lesscss.org/spec.html"") no-repeat 0 4px;
}
#more-shorthands {
margin: 0;
padding: 1px 0 2px 0;
font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
}
";
AssertLessUnchanged(input);
}
[Test]
public void Misc()
{
var input =
@"
.misc {
-moz-border-radius: 2px;
display: -moz-inline-stack;
width: .1em;
background-color: #009998;
background-image: url(images/image.jpg);
background: -webkit-gradient(linear, left top, left bottom, from(red), to(blue));
margin: ;
}
";
AssertLessUnchanged(input);
}
[Test]
public void Important()
{
var input =
@"
#important {
color: red !important;
width: 100%!important;
height: 20px ! important;
}
";
AssertLessUnchanged(input);
}
[Test]
public void ImportantVariable()
{
var input =
@"
@c: white;
#important {
color: @c !important;
}
";
var output =
@"
#important {
color: white !important;
}
";
AssertLess(input, output);
}
[Test]
public void AttributeEquals()
{
var input = @"
input[type=""text""] {
font-weight: normal;
}
";
AssertLessUnchanged(input);
}
[Test]
public void AttributeExists()
{
var input =
@"
h2[title] {
font-size: 100%;
}
[disabled] {
color: transparent;
}
form[data-disabled] {
color: #444;
}
";
AssertLessUnchanged(input);
}
[Test]
public void EmptyUrl()
{
AssertExpressionUnchanged("url()");
}
[Test]
public void CheckUrlWithHorizBarCharacterIsAcceptedWithoutQuotes()
{
// Note: https://github.com/dotless/dotless/issues/30
var input = @"body {
background-image: url(pickture.asp?id=this|thing);
}";
AssertLessUnchanged(input);
}
[Test]
public void CheckUrlWithData()
{
var input = @".help-icon {
background: url(""data:image/gif;base64,R0lGODlhDAAMAMQAAAAAAP////T4/ujx/ery/UKP7k6W71CX71KY71Sa8Gak8XGr8nWu83ev83qv83ux83yx832y85XA9aHH96rN+KvO+KzO+K3O+LnV+cTc+tDj+9Xm+////wAAAAAAAAAAACH5BAEAABwALAAAAAAMAAwAAAVKIMcRVoMgjUWI3BYVcOxs41tIGqbAEQkvgshkECv9XopAzBQrKASX2KmZyTRRzUYia2lqdkWCrbAwxHqtRxMGoYkIFcbhwKCsOCEAOw=="") center bottom no-repeat;
}";
AssertLessUnchanged(input);
}
[Test]
public void CheckUrlWithDataNotQuoted()
{
var input = @".help-icon {
background: #eeeeee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABlBMVEX///////9VfPVsAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg%3D%3D) repeat-y 13em 0;
}";
AssertLessUnchanged(input);
}
[Test]
[Ignore("Bug in dotless")]
public void HttpUrl()
{
AssertExpressionUnchanged(@"url(http://), ""}"", url(""http://}"")");
}
[Test]
[Ignore("Bug in dotless")]
public void HttpUrlClosingBraceOnSameLine()
{
var input = @"
.trickyurl {
image: url(http://); }";
var expected = @"
.trickyurl {
image: url(http://);
}";
AssertLess(input, expected);
}
[Test]
public void HttpUrl3()
{
var input = @"
.trickyurl {
image: url(http://);
}";
var expected = @"
.trickyurl {
image: url(http://);
}";
AssertLess(input, expected);
}
[Test]
public void HttpUrl4()
{
var input = @"
.trickyurl {
image: url(""""), url(http://);
}";
var expected = @"
.trickyurl {
image: url(""""), url(http://);
}";
AssertLess(input, expected);
}
}
}