• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const Path = require('path');
3
4const { test } = require('tap');
5
6const startCLI = require('./start-cli');
7
8test('list scripts', (t) => {
9  const script = Path.join('examples', 'three-lines.js');
10  const cli = startCLI([script]);
11
12  function onFatal(error) {
13    cli.quit();
14    throw error;
15  }
16
17  return cli.waitForInitialBreak()
18    .then(() => cli.waitForPrompt())
19    .then(() => cli.command('scripts'))
20    .then(() => {
21      t.match(
22        cli.output,
23        /^\* \d+: examples(?:\/|\\)three-lines\.js/,
24        'lists the user script');
25      t.notMatch(
26        cli.output,
27        /\d+: buffer\.js <native>/,
28        'omits node-internal scripts');
29    })
30    .then(() => cli.command('scripts(true)'))
31    .then(() => {
32      t.match(
33        cli.output,
34        /\* \d+: examples(?:\/|\\)three-lines\.js/,
35        'lists the user script');
36      t.match(
37        cli.output,
38        /\d+: buffer\.js <native>/,
39        'includes node-internal scripts');
40    })
41    .then(() => cli.quit())
42    .then(null, onFatal);
43});
44