forked from tj/commander.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.command.executableSubcommandDefault.js
56 lines (45 loc) · 1.56 KB
/
test.command.executableSubcommandDefault.js
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
50
51
52
53
54
55
56
var exec = require('child_process').exec
, path = require('path')
, should = require('should');
var bin = path.join(__dirname, './fixtures/pm')
// success case
exec(bin + ' default', function(error, stdout, stderr) {
stdout.should.equal('default\n500\n');
});
// success case (default)
exec(bin, function(error, stdout, stderr) {
stdout.should.equal('default\n500\n');
});
// success case (default) and alisa option
exec(bin + ' -t 600', function(error, stdout, stderr) {
stdout.should.equal('default\n600\n');
});
// success case (default) and option
exec(bin + ' --test 800', function(error, stdout, stderr) {
stdout.should.equal('default\n800\n');
});
// not exist
exec(bin + ' list', function (error, stdout, stderr) {
//stderr.should.equal('\n pm-list(1) does not exist, try --help\n\n');
// TODO error info are not the same in between <=v0.8 and later version
should.notEqual(0, stderr.length);
});
// success case
exec(bin + ' install', function (error, stdout, stderr) {
stdout.should.equal('install\n');
});
// subcommand bin file with explicit extension
exec(bin + ' publish', function (error, stdout, stderr) {
stdout.should.equal('publish\n');
});
// spawn EACCES
exec(bin + ' search', function (error, stdout, stderr) {
// TODO error info are not the same in between <v0.10 and v0.12
should.notEqual(0, stderr.length);
});
// when `bin` is a symbol link for mocking global install
var bin = path.join(__dirname, './fixtures/pmlink')
// success case
exec(bin + ' install', function (error, stdout, stderr) {
stdout.should.equal('install\n');
});