• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const PassThrough = require('stream').PassThrough;
6const readline = require('readline');
7
8common.skipIfDumbTerminal();
9
10// Checks that tab completion still works
11// when output column size is undefined
12
13const iStream = new PassThrough();
14const oStream = new PassThrough();
15
16readline.createInterface({
17  terminal: true,
18  input: iStream,
19  output: oStream,
20  completer: function(line, cb) {
21    cb(null, [['process.stdout', 'process.stdin', 'process.stderr'], line]);
22  }
23});
24
25let output = '';
26
27oStream.on('data', function(data) {
28  output += data;
29});
30
31oStream.on('end', common.mustCall(() => {
32  const expect = 'process.stdout\r\n' +
33                 'process.stdin\r\n' +
34                 'process.stderr';
35  assert.match(output, new RegExp(expect));
36}));
37
38iStream.write('process.s\t');
39
40// Completion works.
41assert.match(output, /process\.std\b/);
42// Completion doesn’t show all results yet.
43assert.doesNotMatch(output, /stdout/);
44
45iStream.write('\t');
46oStream.end();
47