blob: c62a51c9626e2436fb904afcc084795fb091052f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
'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();
function testTerminalMode() {
const r1 = repl.start({
input: stream,
output: stream,
terminal: true
});
process.nextTick(function() {
// manually fire a ^D keypress
stream.emit('data', '\u0004');
});
r1.on('exit', function() {
// should be fired from the simulated ^D keypress
terminalExit++;
testRegularMode();
});
}
function testRegularMode() {
const r2 = repl.start({
input: stream,
output: stream,
terminal: false
});
process.nextTick(function() {
stream.emit('end');
});
r2.on('exit', function() {
// should be fired from the simulated 'end' event
regularExit++;
});
}
process.on('exit', function() {
assert.strictEqual(terminalExit, 1);
assert.strictEqual(regularExit, 1);
});
// start
testTerminalMode();
|