mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

refactor the test/parallel/test-repl-tab-complete.js file by: - making the tests in the file self-contained (instead of all of them sharing the same REPL instance and constantly calling `.clear` on it) - using the test runner with appropriate descriptions to make clearer what is being tested - extracting some tests in their own js test files (to increase isolation of the tests and help with issues such as flakiness) PR-URL: https://github.com/nodejs/node/pull/58636 Reviewed-By: Giovanni Bucci <github@puskin.it> Reviewed-By: James M Snell <jasnell@gmail.com>
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const ArrayStream = require('../common/arraystream');
|
|
const repl = require('repl');
|
|
|
|
// Tab completion in editor mode
|
|
{
|
|
const editorStream = new ArrayStream();
|
|
const editor = repl.start({
|
|
stream: editorStream,
|
|
terminal: true,
|
|
useColors: false
|
|
});
|
|
|
|
editorStream.run(['.clear']);
|
|
editorStream.run(['.editor']);
|
|
|
|
editor.completer('Uin', common.mustCall((_error, data) => {
|
|
assert.deepStrictEqual(data, [['Uint'], 'Uin']);
|
|
}));
|
|
|
|
editorStream.run(['.clear']);
|
|
editorStream.run(['.editor']);
|
|
|
|
editor.completer('var log = console.l', common.mustCall((_error, data) => {
|
|
assert.deepStrictEqual(data, [['console.log'], 'console.l']);
|
|
}));
|
|
}
|
|
|
|
// Regression test for https://github.com/nodejs/node/issues/43528
|
|
{
|
|
const stream = new ArrayStream();
|
|
const replServer = repl.start({
|
|
input: stream,
|
|
output: stream,
|
|
terminal: true,
|
|
});
|
|
|
|
// Editor mode
|
|
replServer.write('.editor\n');
|
|
|
|
replServer.write('a');
|
|
replServer.write(null, { name: 'tab' }); // Should not throw
|
|
|
|
replServer.close();
|
|
}
|