Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
readline: add test for promisified question
  • Loading branch information
chapko committed Jun 5, 2022
commit 473f03c07014043801cf943b6edaad2481a1b116
15 changes: 14 additions & 1 deletion test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ for (let i = 0; i < 12; i++) {
// Calling the question callback with abort signal
{
const [rli] = getInterface({ terminal });
const signal = new AbortController().signal;
const { signal } = new AbortController();
rli.question('foo?', { signal }, common.mustCall((answer) => {
assert.strictEqual(answer, 'bar');
}));
Expand Down Expand Up @@ -1041,6 +1041,19 @@ for (let i = 0; i < 12; i++) {
rli.close();
}

// Calling the promisified question with abort signal
{
const [rli] = getInterface({ terminal });
const question = util.promisify(rli.question).bind(rli);
const { signal } = new AbortController();
question('foo?', { signal })
.then(common.mustCall((answer) => {
assert.strictEqual(answer, 'bar');
}));
rli.write('bar\n');
rli.close();
}

// Aborting a question
{
const ac = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-readline-promises-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ for (let i = 0; i < 12; i++) {
// Calling the question callback with abort signal
{
const [rli] = getInterface({ terminal });
const signal = new AbortController().signal;
const { signal } = new AbortController();
rli.question('foo?', { signal }).then(common.mustCall((answer) => {
assert.strictEqual(answer, 'bar');
}));
Expand Down