diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-04-27 17:05:29 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-05-03 15:49:48 +0200 |
commit | b2ab41e5ae6213b17de8031771585030aea046e2 (patch) | |
tree | b7c400f59474bc3766498bda63fc56f61fdd51c9 /test | |
parent | 8aca66a1f32e436b187e99959c52e112de7147b8 (diff) | |
download | android-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.tar.gz android-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.tar.bz2 android-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.zip |
test: increase readline coverage
PR-URL: https://github.com/nodejs/node/pull/12761
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-readline.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/parallel/test-readline.js b/test/parallel/test-readline.js new file mode 100644 index 0000000000..62a4fe6f48 --- /dev/null +++ b/test/parallel/test-readline.js @@ -0,0 +1,45 @@ +'use strict'; +const common = require('../common'); +const { PassThrough } = require('stream'); +const readline = require('readline'); +const assert = require('assert'); + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', common.mustCall((data) => { + assert.strictEqual(data, 'abc'); + })); + + input.end('abc'); +} + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', common.mustNotCall('must not be called before newline')); + + input.write('abc'); +} + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', common.mustCall((data) => { + assert.strictEqual(data, 'abc'); + })); + + input.write('abc\n'); +} |