Skip to content

Commit

Permalink
Improve some more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Feb 16, 2013
1 parent c8009d8 commit 39527ff
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ module.exports = function () {

it('should error if task file does not exist', function (done) {
cp.exec('node bin/automaton something-that-will-never-exist', function (err, stdout, stderr) {
expect(err).to.be.an(Error);
expect(err.code).to.equal(1);

if (process.platform !== 'win32') { // Windows messes with stdout dunno why
expect(stderr).to.match(/could not find/i);
}
}).on('exit', function (code) {
expect(code).to.equal(1);

done();
});
});

it('should exit with an appropriate code if a task fails', function (done) {
it('should exit with an appropriate code on fail/success', function (done) {
cp.exec('node bin/automaton test/helpers/tasks/dummy-mandatory', function (err, stdout) {
expect(err).to.be.an(Error);
expect(err.code).to.equal(1);

if (process.platform !== 'win32') { // windows messes with stdout dunno why
expect(stdout).to.match(/mandatory/);
}
}).on('exit', function (code) {
expect(code).to.equal(1);

cp.exec('node bin/automaton test/helpers/tasks/dummy-mandatory --mandatory=foo')
.on('exit', function (code) {
.on('exit', function (code) {
expect(code).to.equal(0);
done();
});
Expand All @@ -36,11 +39,13 @@ module.exports = function () {

it('should error when showing help of a malformed/non-task file', function (done) {
cp.exec('node bin/automaton index.js', function (err, stdout, stderr) {
expect(err).to.be.an(Error);
expect(err.code).to.equal(1);

if (process.platform !== 'win32') { // Windows messes with stdout dunno why
expect(stderr).to.match(/task to be an object/i);
expect(stderr).to.match(/unable to get task/i);
}
}).on('exit', function (code) {
expect(code).to.equal(1);

done();
});
});
Expand Down
20 changes: 20 additions & 0 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,26 @@ module.exports = function (automaton) {
]
});
}).to.throwException(/tasks/);

expect(function () {
automaton.run({
tasks: [
{
task: {
tasks: [
{
task: {
tasks: 1
},
description: 'deep'
}
]
},
description: 'copy something'
}
]
});
}).to.throwException(/tasks/);
});

it('should add tasks by id', function (done) {
Expand Down

0 comments on commit 39527ff

Please sign in to comment.