Skip to content

Commit d242b72

Browse files
committed
Added test for LESS, but skipping it for now
1 parent 7a778ea commit d242b72

File tree

4 files changed

+236
-2
lines changed

4 files changed

+236
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"ava": "^0.11.0",
2424
"eslint": "^1.10.2",
25+
"postcss-less": "^0.2.0",
2526
"postcss-scss": "^0.1.5"
2627
},
2728
"scripts": {

test/fixtures/less.expected.less

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
@base: #f938ab;
2+
3+
.box-shadow(@style, @c) when (iscolor(@c)) {
4+
-webkit-box-shadow: @style @c;
5+
will-change: transform;
6+
margin-top: 10px;
7+
box-shadow: @style @c;
8+
}
9+
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
10+
.box-shadow(@style, rgba(0, 0, 0, @alpha));
11+
}
12+
.box {
13+
color: saturate(@base, 5%);
14+
border-color: lighten(@base, 30%);
15+
margin-bottom: 1px;
16+
div {
17+
display: none;
18+
.box-shadow(0 0 5px, 30%)
19+
}
20+
}
21+
#menu a {
22+
color: #111;
23+
.bordered;
24+
}
25+
26+
.post a {
27+
color: red;
28+
.bordered;
29+
}
30+
31+
div {
32+
// numbers are converted into the same units
33+
@conversion-1: 5cm + 10mm; // result is 6cm
34+
@conversion-2: 2 - 3cm - 5mm; // result is -1.5cm
35+
36+
// conversion is impossible
37+
@incompatible-units: 2 + 5px - 3cm; // result is 4px
38+
39+
// example with variables
40+
@base: 5%;
41+
@filler: @base * 2; // result is 10%
42+
@other: @base + @filler; // result is 15%
43+
}
44+
45+
// This component code taken from https://github.com/twbs/bootstrap/
46+
// Badges
47+
// --------------------------------------------------
48+
49+
50+
// Base class
51+
.badge {
52+
border-radius: @badge-border-radius;
53+
font-weight: @badge-font-weight;
54+
padding: 3px 7px;
55+
font-size: @font-size-small;
56+
color: @badge-color;
57+
white-space: nowrap;
58+
line-height: @badge-line-height;
59+
vertical-align: middle;
60+
min-width: 10px;
61+
display: inline-block;
62+
text-align: center;
63+
background-color: @badge-bg;
64+
65+
// Empty badges collapse automatically (not available in IE8)
66+
&:empty {
67+
display: none;
68+
}
69+
70+
// Quick fix for badges in buttons
71+
.btn & {
72+
position: relative;
73+
top: -1px;
74+
}
75+
76+
.btn-xs &,
77+
.btn-group-xs > .btn & {
78+
padding: 1px 5px;
79+
80+
top: 0;
81+
}
82+
83+
// Hover state, but only for links
84+
a& {
85+
&:hover,
86+
&:focus {
87+
color: @badge-link-hover-color;
88+
text-decoration: none;
89+
cursor: pointer;
90+
}
91+
}
92+
93+
// Account for badges in navs
94+
.list-group-item.active > &,
95+
.nav-pills > .active > a > & {
96+
color: @badge-active-color;
97+
background-color: @badge-active-bg;
98+
}
99+
100+
.list-group-item > & {
101+
float: right;
102+
}
103+
104+
.list-group-item > & + & {
105+
margin-right: 5px;
106+
}
107+
108+
.nav-pills > li > a > & {
109+
margin-left: 3px;
110+
}
111+
}

test/fixtures/less.less

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
@base: #f938ab;
2+
3+
.box-shadow(@style, @c) when (iscolor(@c)) {
4+
-webkit-box-shadow: @style @c;
5+
will-change: transform;
6+
margin-top: 10px;
7+
box-shadow: @style @c;
8+
}
9+
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
10+
.box-shadow(@style, rgba(0, 0, 0, @alpha));
11+
}
12+
.box {
13+
color: saturate(@base, 5%);
14+
border-color: lighten(@base, 30%);
15+
margin-bottom: 1px;
16+
div {
17+
display: none;
18+
.box-shadow(0 0 5px, 30%)
19+
}
20+
}
21+
#menu a {
22+
color: #111;
23+
.bordered;
24+
}
25+
26+
.post a {
27+
color: red;
28+
.bordered;
29+
}
30+
31+
div {
32+
// numbers are converted into the same units
33+
@conversion-1: 5cm + 10mm; // result is 6cm
34+
@conversion-2: 2 - 3cm - 5mm; // result is -1.5cm
35+
36+
// conversion is impossible
37+
@incompatible-units: 2 + 5px - 3cm; // result is 4px
38+
39+
// example with variables
40+
@base: 5%;
41+
@filler: @base * 2; // result is 10%
42+
@other: @base + @filler; // result is 15%
43+
}
44+
45+
// This component code taken from https://github.com/twbs/bootstrap/
46+
// Badges
47+
// --------------------------------------------------
48+
49+
50+
// Base class
51+
.badge {
52+
border-radius: @badge-border-radius;
53+
font-weight: @badge-font-weight;
54+
padding: 3px 7px;
55+
font-size: @font-size-small;
56+
color: @badge-color;
57+
white-space: nowrap;
58+
line-height: @badge-line-height;
59+
vertical-align: middle;
60+
min-width: 10px;
61+
display: inline-block;
62+
text-align: center;
63+
background-color: @badge-bg;
64+
65+
// Empty badges collapse automatically (not available in IE8)
66+
&:empty {
67+
display: none;
68+
}
69+
70+
// Quick fix for badges in buttons
71+
.btn & {
72+
position: relative;
73+
top: -1px;
74+
}
75+
76+
.btn-xs &,
77+
.btn-group-xs > .btn & {
78+
padding: 1px 5px;
79+
80+
top: 0;
81+
}
82+
83+
// Hover state, but only for links
84+
a& {
85+
&:hover,
86+
&:focus {
87+
color: @badge-link-hover-color;
88+
text-decoration: none;
89+
cursor: pointer;
90+
}
91+
}
92+
93+
// Account for badges in navs
94+
.list-group-item.active > &,
95+
.nav-pills > .active > a > & {
96+
color: @badge-active-color;
97+
background-color: @badge-active-bg;
98+
}
99+
100+
.list-group-item > & {
101+
float: right;
102+
}
103+
104+
.list-group-item > & + & {
105+
margin-right: 5px;
106+
}
107+
108+
.nav-pills > li > a > & {
109+
margin-left: 3px;
110+
}
111+
}

test/test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ function run(t, input, opts = { }, syntax) {
2222
var inputCSS = fs.readFileSync(inputPath, 'utf8');
2323
var expectCSS = fs.readFileSync(expectPath, 'utf8');
2424

25-
if (syntax && syntax === 'scss') {
26-
syntax = { syntax: require('postcss-scss') };
25+
if (syntax) {
26+
if (syntax === 'scss') {
27+
syntax = { syntax: require('postcss-scss') };
28+
} else if (syntax === 'less') {
29+
syntax = { syntax: require('postcss-less') };
30+
}
2731
} else {
2832
syntax = {};
2933
}
@@ -207,3 +211,10 @@ test('Should insert empty lines between children classes in accordance with opti
207211
'empty-lines-between-children-rules': 2
208212
});
209213
});
214+
215+
test.skip('Should sort LESS files', t => {
216+
return run(t, 'less.less', {
217+
'sort-order': ['...'],
218+
'empty-lines-between-children-rules': 1
219+
}, 'less');
220+
});

0 commit comments

Comments
 (0)