Skip to content

Commit 12df1cf

Browse files
committed
Refactor test to not depend on example code
1 parent bce85ec commit 12df1cf

File tree

1 file changed

+13
-3
lines changed
  • lib/node_modules/@stdlib/_tools/modules/import-require/test

1 file changed

+13
-3
lines changed

lib/node_modules/@stdlib/_tools/modules/import-require/test/test.cli.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// MODULES //
44

55
var resolve = require( 'path' ).resolve;
6+
var join = require( 'path' ).join;
67
var exec = require( 'child_process' ).exec;
78
var tape = require( 'tape' );
89
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
@@ -22,6 +23,7 @@ var opts = {
2223
// FIXTURES //
2324

2425
var PKG_VERSION = require( './../package.json' ).version;
26+
var REQUIRES = readFileSync( join( __dirname, './fixtures/requires.txt' ) );
2527

2628

2729
// TESTS //
@@ -144,8 +146,16 @@ tape( 'the command-line interface prints import and require paths', opts, functi
144146
});
145147

146148
tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) {
147-
var cmd = [
148-
'cat ./examples/index.js',
149+
var str;
150+
var cmd;
151+
152+
str = REQUIRES.toString();
153+
154+
// Replace single quotes with double quotes:
155+
str = replace( str, '\'', '"' );
156+
157+
cmd = [
158+
'echo -n \''+str+'\'',
149159
'|',
150160
process.execPath,
151161
fpath
@@ -157,7 +167,7 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
157167
if ( error ) {
158168
t.fail( error.message );
159169
} else {
160-
t.strictEqual( stdout.toString(), '{"literals":["./../lib"],"expressions":[]}\n', 'expected value' );
170+
t.strictEqual( stdout.toString(), '{"literals":["beep","./boop.js","b","bar","foobar"],"expressions":["\\"./../b\\"+\\"op.js\\""]}\n', 'expected value' );
161171
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
162172
}
163173
t.end();

0 commit comments

Comments
 (0)