Skip to content

Commit f291bc1

Browse files
TrottMylesBorins
authored andcommitted
test: refactor test-repl-definecommand
The test was writing to both REPL input and output but only checking output. Sending output to both streams seems like it was an error. PR-URL: #17795 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a08925d commit f291bc1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/parallel/test-repl-definecommand.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,27 @@ r.defineCommand('say1', {
2323
help: 'help for say1',
2424
action: function(thing) {
2525
output = '';
26-
this.write(`hello ${thing}`);
26+
this.output.write(`hello ${thing}\n`);
2727
this.displayPrompt();
2828
}
2929
});
3030

3131
r.defineCommand('say2', function() {
3232
output = '';
33-
this.write('hello from say2');
33+
this.output.write('hello from say2\n');
3434
this.displayPrompt();
3535
});
3636

3737
inputStream.write('.help\n');
3838
assert(/\n.say1 help for say1\n/.test(output), 'help for say1 not present');
3939
assert(/\n.say2\n/.test(output), 'help for say2 not present');
4040
inputStream.write('.say1 node developer\n');
41-
assert(/> hello node developer/.test(output), 'say1 outputted incorrectly');
41+
assert.ok(output.startsWith('hello node developer\n'),
42+
`say1 output starts incorrectly: "${output}"`);
43+
assert.ok(output.includes('> '),
44+
`say1 output does not include prompt: "${output}"`);
4245
inputStream.write('.say2 node developer\n');
43-
assert(/> hello from say2/.test(output), 'say2 outputted incorrectly');
46+
assert.ok(output.startsWith('hello from say2\n'),
47+
`say2 output starts incorrectly: "${output}"`);
48+
assert.ok(output.includes('> '),
49+
`say2 output does not include prompt: "${output}"`);

0 commit comments

Comments
 (0)