From c7b127025a5e2fd9dc0ee9af22e091475d97e468 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 2 Mar 2016 21:59:17 +0100 Subject: [PATCH] test: repl tab completion test It checks that `eval` is called with `.scope` as an input string. PR-URL: https://github.com/nodejs/node/pull/5534 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-repl-eval-scope.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-repl-eval-scope.js diff --git a/test/parallel/test-repl-eval-scope.js b/test/parallel/test-repl-eval-scope.js new file mode 100644 index 0000000000..b9bace5f7d --- /dev/null +++ b/test/parallel/test-repl-eval-scope.js @@ -0,0 +1,23 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); + +{ + const stream = new common.ArrayStream(); + const options = { + eval: common.mustCall((cmd, context) => { + assert.strictEqual(cmd, '.scope\n'); + assert.deepStrictEqual(context, {animal: 'Sterrance'}); + }), + input: stream, + output: stream, + terminal: true + }; + + const r = repl.start(options); + r.context = {animal: 'Sterrance'}; + + stream.emit('data', '\t'); + stream.emit('.exit\n'); +}