@@ -2,87 +2,87 @@ import postcss from 'postcss';
2
2
import test from 'ava' ;
3
3
import plugin from '../src' ;
4
4
5
- const processing = ( input , opts ) => {
6
- return postcss ( [ plugin ( opts ) ] ) . process ( input ) . css ;
5
+ const processing = ( input , options ) => {
6
+ return postcss ( [ plugin ( options ) ] ) . process ( input ) . css ;
7
7
} ;
8
8
9
9
test ( 'it change circular reference' , t => {
10
- const expected = ':root{ --from: 1; --to: var(--from)} @for $i from 1 to 1' ;
11
- const value = ':root{ --from: 1; --to: var(--from)} @for $i from var(--from) to var(--to)' ;
12
- t . is ( processing ( value ) , expected ) ;
10
+ const expected = ':root{ --from: 1; --to: var(--from)} @for $i from 1 to 1' ;
11
+ const value = ':root{ --from: 1; --to: var(--from)} @for $i from var(--from) to var(--to)' ;
12
+ t . is ( processing ( value ) , expected ) ;
13
13
} ) ;
14
14
15
15
test ( 'it should not throw error if comment exists' , t => {
16
- const expected = ':root{ --from: 1; /* comment */ }' ;
17
- const value = ':root{ --from: 1; /* comment */ }' ;
18
- t . is ( processing ( value ) , expected ) ;
16
+ const expected = ':root{ --from: 1; /* comment */ }' ;
17
+ const value = ':root{ --from: 1; /* comment */ }' ;
18
+ t . is ( processing ( value ) , expected ) ;
19
19
} ) ;
20
20
21
21
test ( 'it should not throw error if comment exists with rule' , t => {
22
- const expected = ':root{ --from: 1; /* comment */ } @for $i from 1 to 2' ;
23
- const value = ':root{ --from: 1; /* comment */ } @for $i from var(--from) to 2' ;
24
- t . is ( processing ( value ) , expected ) ;
22
+ const expected = ':root{ --from: 1; /* comment */ } @for $i from 1 to 2' ;
23
+ const value = ':root{ --from: 1; /* comment */ } @for $i from var(--from) to 2' ;
24
+ t . is ( processing ( value ) , expected ) ;
25
25
} ) ;
26
26
27
27
test ( 'it change first properties for @for' , t => {
28
- const expected = ':root{ --from: 1; } @for $i from 1 to 2' ;
29
- const value = ':root{ --from: 1; } @for $i from var(--from) to 2' ;
30
- t . is ( processing ( value ) , expected ) ;
28
+ const expected = ':root{ --from: 1; } @for $i from 1 to 2' ;
29
+ const value = ':root{ --from: 1; } @for $i from var(--from) to 2' ;
30
+ t . is ( processing ( value ) , expected ) ;
31
31
} ) ;
32
32
33
33
test ( 'it change second properties for @for' , t => {
34
- const expected = ':root{ --to: 2; } @for $i from 1 to 2' ;
35
- const value = ':root{ --to: 2; } @for $i from 1 to var(--to)' ;
36
- t . is ( processing ( value ) , expected ) ;
34
+ const expected = ':root{ --to: 2; } @for $i from 1 to 2' ;
35
+ const value = ':root{ --to: 2; } @for $i from 1 to var(--to)' ;
36
+ t . is ( processing ( value ) , expected ) ;
37
37
} ) ;
38
38
39
39
test ( 'it change two properties for @for' , t => {
40
- const expected = ':root{ --from: 1; --to: 2; } @for $i from 1 to 2' ;
41
- const value = ':root{ --from: 1; --to: 2; } @for $i from var(--from) to var(--to)' ;
42
- t . is ( processing ( value ) , expected ) ;
40
+ const expected = ':root{ --from: 1; --to: 2; } @for $i from 1 to 2' ;
41
+ const value = ':root{ --from: 1; --to: 2; } @for $i from var(--from) to var(--to)' ;
42
+ t . is ( processing ( value ) , expected ) ;
43
43
} ) ;
44
44
45
45
test ( 'it change three properties for @for' , t => {
46
- const expected = ':root{ --from: 1; --to: 2; --step: 5 } @for $i from 1 to 2 by 5' ;
47
- const value = ':root{ --from: 1; --to: 2; --step: 5 } @for $i from var(--from) to var(--to) by var(--step)' ;
48
- t . is ( processing ( value ) , expected ) ;
46
+ const expected = ':root{ --from: 1; --to: 2; --step: 5 } @for $i from 1 to 2 by 5' ;
47
+ const value = ':root{ --from: 1; --to: 2; --step: 5 } @for $i from var(--from) to var(--to) by var(--step)' ;
48
+ t . is ( processing ( value ) , expected ) ;
49
49
} ) ;
50
50
51
51
test ( 'it change two properties for @if' , t => {
52
- const expected = ':root{ --first: 1; --second: 2; } @if 1 < 2' ;
53
- const value = ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second)' ;
54
- t . is ( processing ( value , { atRules : [ 'if' ] } ) , expected ) ;
52
+ const expected = ':root{ --first: 1; --second: 2; } @if 1 < 2' ;
53
+ const value = ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second)' ;
54
+ t . is ( processing ( value , { atRules : [ 'if' ] } ) , expected ) ;
55
55
} ) ;
56
56
57
57
test ( 'it change two properties for @if, @else if' , t => {
58
- const expected = ':root{ --first: 1; --second: 2; } @if 1 < 2 { color: olive; } @else if 1 > 2 { color: red; }' ;
59
- const value = ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second) { color: olive; } @else if var(--first) > var(--second) { color: red; }' ;
60
- t . is ( processing ( value , { atRules : [ 'if' , 'else' ] } ) , expected ) ;
58
+ const expected = ':root{ --first: 1; --second: 2; } @if 1 < 2 { color: olive; } @else if 1 > 2 { color: red; }' ;
59
+ const value = ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second) { color: olive; } @else if var(--first) > var(--second) { color: red; }' ;
60
+ t . is ( processing ( value , { atRules : [ 'if' , 'else' ] } ) , expected ) ;
61
61
} ) ;
62
62
63
63
test ( 'it change multi properties for @each' , t => {
64
- const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz {} @for foo, bar, baz {}' ;
65
- const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array) {} @for var(--array) {}' ;
66
- t . is ( processing ( value , { atRules : [ 'each' ] } ) , expected ) ;
64
+ const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz {} @for foo, bar, baz {}' ;
65
+ const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array) {} @for var(--array) {}' ;
66
+ t . is ( processing ( value , { atRules : [ 'each' ] } ) , expected ) ;
67
67
} ) ;
68
68
69
69
test ( 'it without variables' , t => {
70
- const expected = ':root{ --red: red; } @if var(--green) { color: var(--green) }' ;
71
- const value = ':root{ --red: red; } @if var(--green) { color: var(--green) }' ;
72
- t . is ( processing ( value ) , expected ) ;
70
+ const expected = ':root{ --red: red; } @if var(--green) { color: var(--green) }' ;
71
+ const value = ':root{ --red: red; } @if var(--green) { color: var(--green) }' ;
72
+ t . is ( processing ( value ) , expected ) ;
73
73
} ) ;
74
74
75
75
test ( 'chould change from options variables' , t => {
76
- const expected = '@if green { .text-green { color: var(--green) }}' ;
77
- const value = '@if var(--green) { .text-green { color: var(--green) }}' ;
78
- const variables = {
79
- '--green' : 'green'
80
- } ;
81
- t . is ( processing ( value , { variables : variables } ) , expected ) ;
76
+ const expected = '@if green { .text-green { color: var(--green) }}' ;
77
+ const value = '@if var(--green) { .text-green { color: var(--green) }}' ;
78
+ const variables = {
79
+ '--green' : 'green'
80
+ } ;
81
+ t . is ( processing ( value , { variables : variables } ) , expected ) ;
82
82
} ) ;
83
83
84
84
test ( 'should change for @custom-media' , t => {
85
- const expected = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > 29.25em)' ;
86
- const value = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > var(--breakpoint-xs))' ;
87
- t . is ( processing ( value , { atRules : [ 'custom-media' ] } ) , expected ) ;
85
+ const expected = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > 29.25em)' ;
86
+ const value = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > var(--breakpoint-xs))' ;
87
+ t . is ( processing ( value , { atRules : [ 'custom-media' ] } ) , expected ) ;
88
88
} ) ;
0 commit comments