Skip to content

Commit 35df221

Browse files
committed
Add multiple test
1 parent 7faf006 commit 35df221

File tree

5 files changed

+43
-44
lines changed

5 files changed

+43
-44
lines changed

Gruntfile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,32 @@ module.exports = function(grunt) {
2222
jshintrc: '.jshintrc',
2323
},
2424
},
25-
25+
2626
// Before generating any new files, remove any previously-created files.
2727
clean: {
2828
tests: ['test/fixtures/tmp_*.css'],
2929
},
3030

3131
// Configuration to be run (and then tested).
3232
csscomb: {
33-
default_option: {
33+
main: {
3434
files: {
3535
'test/fixtures/tmp_resort.css': ['test/fixtures/style.css'],
3636
}
3737
},
38-
sort_option: {
38+
custom: {
3939
options: {
4040
sortOrder: 'test/fixtures/sort.json'
4141
},
4242
files: {
4343
'test/fixtures/tmp_customsort.css': ['test/fixtures/style.css'],
4444
}
45+
},
46+
multiple: {
47+
files: {
48+
'test/fixtures/tmp_multi1.css': ['test/fixtures/multi1.css'],
49+
'test/fixtures/tmp_multi2.css': ['test/fixtures/multi2.css'],
50+
}
4551
}
4652
},
4753

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ grunt.initConfig({
7676

7777
## Release History
7878

79+
+ v0.5.0: Add error handling.
7980
+ v0.4.0: Move to csscomb's repository.
8081
+ v0.3.0: Fix sort option bug.
8182
+ v0.2.0: Fix bugs.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "grunt-csscomb",
33
"description": "The grunt plugin for sorting CSS properties in specific order.",
4-
"version": "0.4.1",
4+
"version": "0.5.0",
55
"homepage": "https://github.com/csscomb/grunt-csscomb",
66
"author": {
77
"name": "Koji Ishimoto",

tasks/csscomb.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ module.exports = function(grunt) {
1010

1111
grunt.registerMultiTask('csscomb', 'Sorting CSS properties in specific order.', function() {
1212
var fs = require('fs'),
13-
path = require('path'),
14-
exec = require('child_process').exec;
15-
var done = this.async(),
16-
realPath = path.dirname(fs.realpathSync(__filename)),
17-
cssComb = 'php ' + realPath + '/lib/csscomb.php',
18-
fileSrc = '',
19-
fileDest = '',
20-
fileSort = '',
21-
options = this.options({
22-
sortOrder: null
23-
});
13+
path = require('path'),
14+
exec = require('child_process').exec;
15+
var command,
16+
done = this.async(),
17+
realPath = path.dirname(fs.realpathSync(__filename)),
18+
cssComb = 'php ' + realPath + '/lib/csscomb.php',
19+
fileSrc = '',
20+
fileDest = '',
21+
fileSort = '',
22+
options = this.options({
23+
sortOrder: null
24+
});
25+
2426
if (options.sortOrder !== null) {
2527
if (grunt.file.exists(options.sortOrder)) {
2628
fileSort = ' -s ' + options.sortOrder;
@@ -33,6 +35,7 @@ module.exports = function(grunt) {
3335
function puts(error, stdout, stderr) {
3436
if (error !== null) {
3537
grunt.log.error(error);
38+
3639
} else {
3740
grunt.log.ok(stdout);
3841
}
@@ -54,10 +57,10 @@ module.exports = function(grunt) {
5457
if (file.dest !== null) {
5558
fileDest = ' -o ' + file.dest;
5659
}
57-
var command = cssComb + fileSort + fileSrc + fileDest;
60+
command = cssComb + fileSort + fileSrc + fileDest;
5861
exec(command, puts);
59-
// grunt.log.writeln('`' + command + '` was initiated.');
62+
grunt.verbose.writeln('`' + command + '` was initiated.');
6063
});
64+
6165
});
62-
6366
};

test/csscomb_test.js

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,8 @@
22

33
var grunt = require('grunt');
44

5-
/*
6-
======== A Handy Little Nodeunit Reference ========
7-
https://github.com/caolan/nodeunit
8-
9-
Test methods:
10-
test.expect(numAssertions)
11-
test.done()
12-
Test assertions:
13-
test.ok(value, [message])
14-
test.equal(actual, expected, [message])
15-
test.notEqual(actual, expected, [message])
16-
test.deepEqual(actual, expected, [message])
17-
test.notDeepEqual(actual, expected, [message])
18-
test.strictEqual(actual, expected, [message])
19-
test.notStrictEqual(actual, expected, [message])
20-
test.throws(block, [error], [message])
21-
test.doesNotThrow(block, [error], [message])
22-
test.ifError(value)
23-
*/
24-
255
exports.csscomb = {
26-
setUp: function(done) {
27-
// setup here if necessary
28-
done();
29-
},
30-
default_option: function(test) {
6+
main: function(test) {
317
test.expect(1);
328

339
var actual = grunt.file.read('test/fixtures/tmp_resort.css');
@@ -36,13 +12,26 @@ exports.csscomb = {
3612

3713
test.done();
3814
},
39-
sort_option: function(test) {
15+
custom: function(test) {
4016
test.expect(1);
4117

4218
var actual = grunt.file.read('test/fixtures/tmp_customsort.css');
4319
var expected = grunt.file.read('test/expected/customsort.css');
4420
test.equal(actual, expected, 'sholud be custom sorted.');
4521

22+
test.done();
23+
},
24+
mutiple: function(test) {
25+
test.expect(2);
26+
27+
var actual = grunt.file.read('test/fixtures/tmp_multi1.css');
28+
var expected = grunt.file.read('test/expected/multi1.css');
29+
test.equal(actual, expected, 'sholud be sorted.');
30+
31+
var actual2 = grunt.file.read('test/fixtures/tmp_multi2.css');
32+
var expected2 = grunt.file.read('test/expected/multi2.css');
33+
test.equal(actual2, expected2, 'sholud be sorted.');
34+
4635
test.done();
4736
}
4837
};

0 commit comments

Comments
 (0)