Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test repl reset event #16836

Closed
Closed
Changes from 2 commits
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
10 changes: 7 additions & 3 deletions test/parallel/test-repl-reset-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ common.globalCheck = false;

const assert = require('assert');
const repl = require('repl');
const util = require('util');

// Create a dummy stream that does nothing
const dummy = new common.ArrayStream();
Expand All @@ -38,11 +39,13 @@ function testReset(cb) {
r.context.foo = 42;
r.on('reset', common.mustCall(function(context) {
assert(!!context, 'REPL did not emit a context with reset event');
assert.strictEqual(context, r.context, 'REPL emitted incorrect context');
assert.strictEqual(context, r.context, 'REPL emitted incorrect context.' +
`context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`);
assert.strictEqual(
context.foo,
undefined,
'REPL emitted the previous context, and is not using global as context'
'REPL emitted the previous context, and is not using global as context.' +
`context.foo is ${context.foo}, expected undefined.`
);
context.foo = 42;
cb();
Expand All @@ -61,7 +64,8 @@ function testResetGlobal() {
assert.strictEqual(
context.foo,
42,
'"foo" property is missing from REPL using global as context'
'"foo" property is different from REPL using global as context.' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Probably should be a space at the end of the string on this line or else a space at the beginning of the string on the next line? Same for two other instances above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, tell me what'd prefer :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdriVanHoudt I think we prefer @Trott's suggested style for most of the codebase :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdriVanHoudt Space at the end is more typical throughout the code base as far as I've noticed, so go with that I guess? But either would be fine.

`context.foo is ${context.foo}, expected 42.`
);
}));
r.resetContext();
Expand Down