collectable.js
900 字节
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
var noptify = require('..');
var assert = require('assert');
describe('Collectable', function() {
it('provides the helper method to read from stdin', function() {
var program = noptify();
assert.ok(typeof program.stdin === 'function', 'stdin defined');
});
it('is invoked only when .parse() is called', function(done) {
var program = noptify(['', '']);
var str = 'testing out stdin helper';
program.stdin(function(err, res) {
assert.equal(res, str);
done();
});
program.parse();
process.nextTick(function() {
process.stdin.emit('data', str);
process.stdin.emit('end');
});
});
it('.files()', function(done) {
var program = noptify(['', '', 'test/fixtures/a.js', 'test/fixtures/b.js']);
program.parse();
program.files(function(err, data) {
assert.equal(data, 'a\nb\n');
done();
});
});
});