Skip to content

Commit

Permalink
test: increase coverage for repl
Browse files Browse the repository at this point in the history
Refs: https://coverage.nodejs.org/coverage-7abc7e45b2e17730/lib/internal/repl.js.html#L33

PR-URL: #38559
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
Lxxyx authored and targos committed May 17, 2021
1 parent dcae032 commit 16b2fb4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-repl-envvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const stream = require('stream');
const REPL = require('internal/repl');
const assert = require('assert');
const inspect = require('util').inspect;
const { REPL_MODE_SLOPPY, REPL_MODE_STRICT } = require('repl');

const tests = [
{
Expand All @@ -33,6 +34,14 @@ const tests = [
env: { NODE_NO_READLINE: '0' },
expected: { terminal: true, useColors: true }
},
{
env: { NODE_REPL_MODE: 'sloppy' },
expected: { terminal: true, useColors: true, replMode: REPL_MODE_SLOPPY }
},
{
env: { NODE_REPL_MODE: 'strict' },
expected: { terminal: true, useColors: true, replMode: REPL_MODE_STRICT }
},
];

function run(test) {
Expand All @@ -54,6 +63,8 @@ function run(test) {
`Expected ${inspect(expected)} with ${inspect(env)}`);
assert.strictEqual(repl.useColors, expected.useColors,
`Expected ${inspect(expected)} with ${inspect(env)}`);
assert.strictEqual(repl.replMode, expected.replMode || REPL_MODE_SLOPPY,
`Expected ${inspect(expected)} with ${inspect(env)}`);
for (const key of Object.keys(env)) {
delete process.env[key];
}
Expand Down

0 comments on commit 16b2fb4

Please sign in to comment.