|
| 1 | +var postcss = require('postcss'); |
| 2 | +var expect = require('chai').expect; |
| 3 | + |
| 4 | +var plugin = require('../'); |
| 5 | + |
| 6 | +var test = function (input, output, opts) { |
| 7 | + expect(postcss([plugin(opts) ]).process(input).css).to.eql(output); |
| 8 | +}; |
| 9 | + |
| 10 | +describe('postcss-at-rules-variables', function () { |
| 11 | + |
| 12 | + it('it change first properties for @for', function(){ |
| 13 | + test( |
| 14 | + ':root{ --from: 1; } @for $i from var(--from) to 2', |
| 15 | + ':root{ --from: 1; } @for $i from 1 to 2' |
| 16 | + ); |
| 17 | + }); |
| 18 | + |
| 19 | + it('it change second properties for @for', function(){ |
| 20 | + test( |
| 21 | + ':root{ --to: 2; } @for $i from 1 to var(--to)', |
| 22 | + ':root{ --to: 2; } @for $i from 1 to 2' |
| 23 | + ); |
| 24 | + }); |
| 25 | + |
| 26 | + it('it change two properties for @for', function(){ |
| 27 | + test( |
| 28 | + ':root{ --from: 1; --to: 2; } @for $i from var(--from) to var(--to)', |
| 29 | + ':root{ --from: 1; --to: 2; } @for $i from 1 to 2' |
| 30 | + ); |
| 31 | + }); |
| 32 | + |
| 33 | + it('it change three properties for @for', function(){ |
| 34 | + test( |
| 35 | + ':root{ --from: 1; --to: 2; --step: 5 } @for $i from var(--from) to var(--to) by var(--step)', |
| 36 | + ':root{ --from: 1; --to: 2; --step: 5 } @for $i from 1 to 2 by 5' |
| 37 | + ); |
| 38 | + }); |
| 39 | + |
| 40 | + it('it change two properties for @if', function(){ |
| 41 | + test( |
| 42 | + ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second)', |
| 43 | + ':root{ --first: 1; --second: 2; } @if 1 < 2', |
| 44 | + { atRules: ['if'] } |
| 45 | + ); |
| 46 | + }); |
| 47 | + |
| 48 | + it('it change two properties for @if, @else if', function(){ |
| 49 | + test( |
| 50 | + ':root{ --first: 1; --second: 2; } @if var(--first) < var(--second) { color: olive; } @else if var(--first) > var(--second) { color: red; }', |
| 51 | + ':root{ --first: 1; --second: 2; } @if 1 < 2 { color: olive; } @else if 1 > 2 { color: red; }', |
| 52 | + { atRules: ['if', 'else'] } |
| 53 | + ); |
| 54 | + }); |
| 55 | + |
| 56 | + it('it change multi properties for @each', function(){ |
| 57 | + test( |
| 58 | + ':root{ --array: foo, bar, baz; } @each $val in var(--array)', |
| 59 | + ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz', |
| 60 | + { atRules: ['each'] } |
| 61 | + ); |
| 62 | + }); |
| 63 | + |
| 64 | +}); |
0 commit comments