| 1 |
var Command = require('../../lib/command'); |
| 2 |
|
| 3 |
module.exports = { |
| 4 |
"should return command list": function (test) { |
| 5 |
var cmdList = Command.getCommandList(); |
| 6 |
test.ok(cmdList.length > 0); |
| 7 |
cmdList.forEach(function (name) { |
| 8 |
var command = Command.create(name); |
| 9 |
test.ok(command.synopsis && command.synopsis()); |
| 10 |
test.ok(command.usage && typeof command.usage === 'function'); |
| 11 |
command.usage(); |
| 12 |
test.ok(command.run && typeof command.run === 'function'); |
| 13 |
}); |
| 14 |
test.done(); |
| 15 |
}, |
| 16 |
"should run help for all commands without any barfs": function (test) { |
| 17 |
var cmdList = Command.getCommandList(), |
| 18 |
help = Command.create('help'), |
| 19 |
handler = function (err) { test.ok(!err); }; |
| 20 |
help.run([], handler); |
| 21 |
help.run(['foobar'], handler); |
| 22 |
help.run(['foobar', 'foobar', 'foobar'], handler); |
| 23 |
cmdList.forEach(function (name) { |
| 24 |
if (name !== 'help') { |
| 25 |
help.run([ name ], handler); |
| 26 |
} |
| 27 |
}); |
| 28 |
test.done(); |
| 29 |
}, |
| 30 |
"should throw on non-existent command": function (test) { |
| 31 |
test.throws(function () { Command.create('nonexistent-command'); }, |
| 32 |
/existent/); |
| 33 |
test.done(); |
| 34 |
} |
| 35 |
}; |