Skip to content

Commit a5b8d09

Browse files
courtnekevanlucas
authored andcommitted
test: clean up repl-reset-event file
* Change vars to let/const * Add mustCall * equal -> strictEqual * remove timeout PR-URL: #9931 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 599a2a9 commit a5b8d09

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed
+22-25
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
11
'use strict';
2-
var common = require('../common');
2+
const common = require('../common');
33
common.globalCheck = false;
44

5-
var assert = require('assert');
6-
var repl = require('repl');
5+
const assert = require('assert');
6+
const repl = require('repl');
77

88
// Create a dummy stream that does nothing
99
const dummy = new common.ArrayStream();
1010

1111
function testReset(cb) {
12-
var r = repl.start({
12+
const r = repl.start({
1313
input: dummy,
1414
output: dummy,
1515
useGlobal: false
1616
});
1717
r.context.foo = 42;
18-
r.on('reset', function(context) {
18+
r.on('reset', common.mustCall(function(context) {
1919
assert(!!context, 'REPL did not emit a context with reset event');
20-
assert.equal(context, r.context, 'REPL emitted incorrect context');
21-
assert.equal(context.foo, undefined, 'REPL emitted the previous context' +
22-
', and is not using global as context');
20+
assert.strictEqual(context, r.context, 'REPL emitted incorrect context');
21+
assert.strictEqual(
22+
context.foo,
23+
undefined,
24+
'REPL emitted the previous context, and is not using global as context'
25+
);
2326
context.foo = 42;
2427
cb();
25-
});
28+
}));
2629
r.resetContext();
2730
}
2831

29-
function testResetGlobal(cb) {
30-
var r = repl.start({
32+
function testResetGlobal() {
33+
const r = repl.start({
3134
input: dummy,
3235
output: dummy,
3336
useGlobal: true
3437
});
3538
r.context.foo = 42;
36-
r.on('reset', function(context) {
37-
assert.equal(context.foo, 42,
38-
'"foo" property is missing from REPL using global as context');
39-
cb();
40-
});
39+
r.on('reset', common.mustCall(function(context) {
40+
assert.strictEqual(
41+
context.foo,
42+
42,
43+
'"foo" property is missing from REPL using global as context'
44+
);
45+
}));
4146
r.resetContext();
4247
}
4348

44-
var timeout = setTimeout(function() {
45-
common.fail('Timeout, REPL did not emit reset events');
46-
}, 5000);
47-
48-
testReset(function() {
49-
testResetGlobal(function() {
50-
clearTimeout(timeout);
51-
});
52-
});
49+
testReset(common.mustCall(testResetGlobal));

0 commit comments

Comments
 (0)