test.js
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var grunt = require('grunt')
, lf = grunt.util.linefeed
, path = require('path')
, fs = require('fs')
, assert = require('assert')
, testDir = path.join(process.cwd(), 'test')
, opts = { gruntfile: path.join(testDir, 'Gruntfile.js') }
, tasks = [
'exec:test1'
, 'exec:test2'
, 'exec:test3:42:love'
, 'exec:test4'
, 'exec:test5'
, 'exec:test6'
, 'exec:test7'
, 'exec:test8'
, 'exec:test9'
, 'exec:test10'
];
grunt.tasks(tasks, opts, function() {
var tests = [
{ name: 'test1', expected: 'bruce willis was dead' + lf }
, { name: 'test2' , expected: 'grunt@' + grunt.version + lf }
, {
name: 'test3'
, expected: [
'the answer to life is 42', 'thoughts on tacos? love'
].join(', ') + lf
}
, {
name: 'test4'
, expected:'you can use callback, and error, stdout, stderr can be' +
' used as arguments' + lf
}
, { name: 'test7', expected: 'you do not even need an object' + lf }
]
, outputPath;
tests.forEach(function(test) {
outputPath = path.join(testDir, test.name);
assert.equal(fs.readFileSync(outputPath, 'utf8'), test.expected);
// clean up
fs.unlinkSync(outputPath);
grunt.log.ok(test.name +' passed');
});
});