Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Added tests for PR #122 (amendable)
Browse files Browse the repository at this point in the history
Note though that this test case

 - is not Node 4 compatible since the plugin is not Node 4 compatible
 - might not be reliably since the regression case depends on postcss'
   and postcss-preset-env's internal workings and might be
   false-positive (false-non-failing) when there's actually an error.
  • Loading branch information
tholewebgods committed Apr 10, 2019
1 parent 613984f commit ec4087d
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ module.exports = function(grunt) {
},
src: 'test/fixtures/a.scss',
dest: 'tmp/noWriteDest.scss'
},
ensureSequentialRun1: {
options: {
processors: [require("postcss-preset-env")]
},
files: [{
src: 'test/fixtures/b1.css',
dest: 'tmp/ensureSequentialRun1sequence1.css'
}, {
src: 'test/fixtures/b2.css',
dest: 'tmp/ensureSequentialRun2sequence1.css'
}]
},
// Same issue, different order. The result shall be the same
ensureSequentialRun2: {
options: {
processors: [require("postcss-preset-env")]
},
files: [{
src: 'test/fixtures/b2.css',
dest: 'tmp/ensureSequentialRun2sequence2.css'
}, {
src: 'test/fixtures/b1.css',
dest: 'tmp/ensureSequentialRun1sequence2.css'
}]
}
},

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-nodeunit": "^1.0.0",
"load-grunt-tasks": "^3.1.0",
"postcss-preset-env": "^6.6.0",
"postcss-scss": "^1.0.2",
"time-grunt": "^1.1.0"
},
Expand Down
9 changes: 9 additions & 0 deletions test/expected/ensureSequentialRun1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

:root {
--foo: #333;
}

.moo {
color: #333;
color: var(--foo);
}
4 changes: 4 additions & 0 deletions test/expected/ensureSequentialRun2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

:root {
--foo: #666;
}
8 changes: 8 additions & 0 deletions test/fixtures/b1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

:root {
--foo: #333;
}

.moo {
color: var(--foo);
}
4 changes: 4 additions & 0 deletions test/fixtures/b2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

:root {
--foo: #666;
}
33 changes: 33 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,37 @@ exports.gruntPostcss = {
test.ok(!grunt.file.exists('tmp/noWriteDest.scss'));
test.done();
},

ensureSequentialRun1: function(test) {
var actual = {
css1: grunt.file.read('tmp/ensureSequentialRun1sequence1.css'),
css2: grunt.file.read('tmp/ensureSequentialRun2sequence1.css')
};

var expected = {
css1: grunt.file.read('test/expected/ensureSequentialRun1.css'),
css2: grunt.file.read('test/expected/ensureSequentialRun2.css'),
};

test.strictEqual(actual.css1, expected.css1);
test.strictEqual(actual.css2, expected.css2);
test.done();
},

// Identical validation
ensureSequentialRun2: function(test) {
var actual = {
css1: grunt.file.read('tmp/ensureSequentialRun1sequence2.css'),
css2: grunt.file.read('tmp/ensureSequentialRun2sequence2.css')
};

var expected = {
css1: grunt.file.read('test/expected/ensureSequentialRun1.css'),
css2: grunt.file.read('test/expected/ensureSequentialRun2.css'),
};

test.strictEqual(actual.css1, expected.css1);
test.strictEqual(actual.css2, expected.css2);
test.done();
},
};

0 comments on commit ec4087d

Please sign in to comment.