From 05ba90243c513039fa4b78eb7b1a5dbf98c5969d Mon Sep 17 00:00:00 2001 From: Prince J Wesley Date: Sat, 30 Jul 2016 23:06:14 +0530 Subject: [PATCH] Add test --- test/parallel/test-repl-deprecated.js | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/parallel/test-repl-deprecated.js diff --git a/test/parallel/test-repl-deprecated.js b/test/parallel/test-repl-deprecated.js new file mode 100644 index 00000000000000..eabc313f475986 --- /dev/null +++ b/test/parallel/test-repl-deprecated.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); + +const expected = [ + 'replServer.convertToContext() is deprecated' +]; + +process.on('warning', common.mustCall((warning) => { + assert.strictEqual(warning.name, 'DeprecationWarning'); + assert.notStrictEqual(expected.indexOf(warning.message), -1, + `unexpected error message: "${warning.message}"`); + // Remove a warning message after it is seen so that we guarantee that we get + // each message only once. + expected.splice(expected.indexOf(warning.message), 1); +}, expected.length)); + +// Create a dummy stream that does nothing +const stream = new common.ArrayStream(); + +const replServer = repl.start({ + input: stream, + output: stream +}); + +const cmd = replServer.convertToContext('var name = "nodejs"'); +assert.strictEqual(cmd, 'self.context.name = "nodejs"');