summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl-end-emits-exit.js
diff options
context:
space:
mode:
authorBradley Farias <bradley.meck@gmail.com>2017-12-22 11:19:50 -0600
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-10 14:19:54 +0100
commitde848ac1e0483327a2ce8716c3f8567eaeacb660 (patch)
tree5395e33d22cd318f618b24752e178f68f40e851f /test/parallel/test-repl-end-emits-exit.js
parent6007a9cc0e361d428123e4c0f74024c6cd7815f4 (diff)
downloadandroid-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.tar.gz
android-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.tar.bz2
android-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.zip
repl: refactor tests to not rely on timing
Tests relying on synchronous timing have been migrated to use events. PR-URL: https://github.com/nodejs/node/pull/17828 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-repl-end-emits-exit.js')
-rw-r--r--test/parallel/test-repl-end-emits-exit.js18
1 files changed, 4 insertions, 14 deletions
diff --git a/test/parallel/test-repl-end-emits-exit.js b/test/parallel/test-repl-end-emits-exit.js
index 67f667eeb3..dd9ad5c1eb 100644
--- a/test/parallel/test-repl-end-emits-exit.js
+++ b/test/parallel/test-repl-end-emits-exit.js
@@ -21,10 +21,7 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const repl = require('repl');
-let terminalExit = 0;
-let regularExit = 0;
// Create a dummy stream that does nothing
const stream = new common.ArrayStream();
@@ -41,11 +38,10 @@ function testTerminalMode() {
stream.emit('data', '\u0004');
});
- r1.on('exit', function() {
+ r1.on('exit', common.mustCall(function() {
// should be fired from the simulated ^D keypress
- terminalExit++;
testRegularMode();
- });
+ }));
}
function testRegularMode() {
@@ -59,17 +55,11 @@ function testRegularMode() {
stream.emit('end');
});
- r2.on('exit', function() {
+ r2.on('exit', common.mustCall(function() {
// should be fired from the simulated 'end' event
- regularExit++;
- });
+ }));
}
-process.on('exit', function() {
- assert.strictEqual(terminalExit, 1);
- assert.strictEqual(regularExit, 1);
-});
-
// start
testTerminalMode();