Skip to content

Commit 83fb9dd

Browse files
committed
test: raise coverage to 100%
1 parent f041cd3 commit 83fb9dd

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = (config, root) => {
3131
}).then(res => {
3232
require('./update')({ root: root });
3333
/* istanbul ignore if */
34-
if (!settings.return && res !== undefined) {
34+
if (!settings.return && res != undefined) { // jshint ignore:line
3535
return console.log(res);
3636
}
3737

test/integration/help.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ test('user can trigger usage error', function (t) {
9090
t.equal(e.code, 'BAD_ARGS', 'bad arguments');
9191
t.match(e.message, /This did not work/i, 'user error shown');
9292
});
93-
});
93+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
var test = require('tap-only');
4+
var sampleArgs = ['node', 'script.js'];
5+
var fixtures = __dirname + '/../fixtures';
6+
var clite = require('../../');
7+
8+
test('should not echo on empty resolve', function (t) {
9+
process.argv = sampleArgs.slice();
10+
var logged = false;
11+
console.log = function (s) {
12+
logged = true;
13+
t.fail('logged: ' + s);
14+
};
15+
16+
return clite({
17+
commands: { _ : 'echo' },
18+
return: false,
19+
}, fixtures + '/basic-clite').then(function () {
20+
t.notOk(logged, 'kept silent as expected');
21+
});
22+
});

test/integration/stdin.test.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
'use strict';
22

3-
var test = require('tap').test;
3+
var test = require('tap-only');
44
var sampleArgs = ['node', 'script.js'];
55
var fixtures = __dirname + '/../fixtures';
66
var fs = require('fs');
77
var body = fs.readFileSync(__filename, 'utf8');
8-
var stdin = require('mock-stdin').stdin();
98
var clite = require('../../');
109

1110
test('reads from stdin', function (t) {
1211
process.argv = sampleArgs.concat('echo');
1312
delete process.env.TAP; // remove test check in lib/read-stdin
13+
var stdin = require('mock-stdin').stdin();
1414

1515
var p = clite({
1616
commands: {
@@ -22,6 +22,27 @@ test('reads from stdin', function (t) {
2222
process.env.TAP = '1'; // restore tap
2323
});
2424

25+
// send our mocked out stdin
26+
stdin.send(body, 'ascii');
27+
stdin.send(null);
28+
return p;
29+
});
30+
31+
test('no command but has body', function (t) {
32+
process.argv = sampleArgs.slice();
33+
delete process.env.TAP; // remove test check in lib/read-stdin
34+
var stdin = require('mock-stdin').stdin();
35+
36+
var p = clite({
37+
commands: {
38+
echo: './echo'
39+
},
40+
return: true,
41+
}, fixtures + '/basic-clite').catch(function (e) {
42+
t.equals(e.code, 'NO_COMMAND', 'no command given');
43+
process.env.TAP = '1'; // restore tap
44+
});
45+
2546
// send our mocked out stdin
2647
stdin.send(body, 'ascii');
2748
stdin.send(null);

0 commit comments

Comments
 (0)