@@ -2,87 +2,87 @@ import postcss from 'postcss';
22import test from 'ava' ;
33import plugin from '../src' ;
44
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 ;
77} ;
88
99test ( '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 ) ;
1313} ) ;
1414
1515test ( '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 ) ;
1919} ) ;
2020
2121test ( '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 ) ;
2525} ) ;
2626
2727test ( '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 ) ;
3131} ) ;
3232
3333test ( '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 ) ;
3737} ) ;
3838
3939test ( '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 ) ;
4343} ) ;
4444
4545test ( '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 ) ;
4949} ) ;
5050
5151test ( '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 ) ;
5555} ) ;
5656
5757test ( '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 ) ;
6161} ) ;
6262
6363test ( '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 ) ;
6767} ) ;
6868
6969test ( '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 ) ;
7373} ) ;
7474
7575test ( '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 ) ;
8282} ) ;
8383
8484test ( '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 ) ;
8888} ) ;
0 commit comments