0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/known_issues/test-repl-require-context.js
Miguel Angel Asencio Hurtado 9a5c3cf185
test: continue normalizing fixtures use
PR-URL: https://github.com/nodejs/node/pull/14716
Refs: https://github.com/nodejs/node/pull/14332
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-08-27 21:14:34 -03:00

31 lines
937 B
JavaScript

'use strict';
// Refs: https://github.com/nodejs/node/issues/7788
const common = require('../common');
const assert = require('assert');
const path = require('../common/fixtures').path;
const repl = require('repl');
const stream = require('stream');
const inputStream = new stream.PassThrough();
const outputStream = new stream.PassThrough();
const fixture = path('is-object.js');
const r = repl.start({
input: inputStream,
output: outputStream,
useGlobal: false
});
let output = '';
outputStream.setEncoding('utf8');
outputStream.on('data', (data) => output += data);
r.on('exit', common.mustCall(() => {
const results = output.replace(/^> /mg, '').split('\n');
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
}));
inputStream.write('const isObject = (obj) => obj.constructor === Object;\n');
inputStream.write('isObject({});\n');
inputStream.write(`require('${fixture}').isObject({});\n`);
r.close();