Skip to content

Commit 05ba902

Browse files
committed
Add test
1 parent 60f4a9f commit 05ba902

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const repl = require('repl');
5+
6+
const expected = [
7+
'replServer.convertToContext() is deprecated'
8+
];
9+
10+
process.on('warning', common.mustCall((warning) => {
11+
assert.strictEqual(warning.name, 'DeprecationWarning');
12+
assert.notStrictEqual(expected.indexOf(warning.message), -1,
13+
`unexpected error message: "${warning.message}"`);
14+
// Remove a warning message after it is seen so that we guarantee that we get
15+
// each message only once.
16+
expected.splice(expected.indexOf(warning.message), 1);
17+
}, expected.length));
18+
19+
// Create a dummy stream that does nothing
20+
const stream = new common.ArrayStream();
21+
22+
const replServer = repl.start({
23+
input: stream,
24+
output: stream
25+
});
26+
27+
const cmd = replServer.convertToContext('var name = "nodejs"');
28+
assert.strictEqual(cmd, 'self.context.name = "nodejs"');

0 commit comments

Comments
 (0)