Skip to content

Commit

Permalink
Update tests to contain valid CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
antyakushev committed May 6, 2015
1 parent eb7d737 commit c0fd7a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.1
* Update examples and tests to contain valid CSS

## 1.0.0
* Update according to the plugin guidelines
* Bump to major release, since in 0.2.0 breaking changes were introduced and alas were not bumped.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-for",
"version": "1.0.0",
"version": "1.0.1",
"description": "PostCSS plugin that enables SASS-like for loop syntax in your CSS",
"keywords": [
"postcss",
Expand Down
18 changes: 9 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ var test = function (input, output, opts) {
describe('postcss-for', function () {

it('it iterates from and to', function () {
test('@for $i from 1 to 2 { .b-$i { width: $i px; } }',
'.b-1 {\n width: 1 px\n}\n.b-2 {\n width: 2 px\n}');
test('@for $i from 1 to 2 { .b-$i { width: $(i)px; } }',
'.b-1 {\n width: 1px\n}\n.b-2 {\n width: 2px\n}');
});

it('it iterates from bigger to smaller', function () {
test('@for $i from 3 to 1 { .b-$i { width: $i px; } }',
'.b-3 {\n width: 3 px\n}\n.b-2 {\n width: 2 px\n}\n.b-1 {\n width: 1 px\n}');
test('@for $i from 3 to 1 { .b-$i { width: $(i)px; } }',
'.b-3 {\n width: 3px\n}\n.b-2 {\n width: 2px\n}\n.b-1 {\n width: 1px\n}');
});

it('it iterates from and to by two', function () {
test('@for $i from 1 to 4 by 2 { .b-$i { width: $i px; } }',
'.b-1 {\n width: 1 px\n}\n.b-3 {\n width: 3 px\n}');
test('@for $i from 1 to 4 by 2 { .b-$i { width: $(i)px; } }',
'.b-1 {\n width: 1px\n}\n.b-3 {\n width: 3px\n}');
});

it('it throws an error on wrong syntax', function () {
expect(function () {
test('@for $i since 1 until 3 { .b-$i { width: $i px; } }');
test('@for $i since 1 until 3 { .b-$i { width: $(i)px; } }');
}).to.throw('<css input>:1:1: Wrong loop syntax');
});

it('it throws an error on wrong range parameters', function () {
expect(function () {
test('@for $i from a to c { .b-$i { width: $i px; } }');
test('@for $i from a to c { .b-$i { width: $(i)px; } }');
}).to.throw('<css input>:1:1: Range parameter should be a number');
});

it('it throws an error if range parameter is a variable', function () {
expect(function () {
test('@for $i from 1 to $columns { .b-$i { width: $i px; } }');
test('@for $i from 1 to $columns { .b-$i { width: $(i)px; } }');
}).to.throw('<css input>:1:1: Variable cannot be used as a range parameter');
});

Expand Down

0 comments on commit c0fd7a5

Please sign in to comment.