11cb0ef41Sopenharmony_ciconst t = require('tap')
21cb0ef41Sopenharmony_ciconst MockRegistry = require('@npmcli/mock-registry')
31cb0ef41Sopenharmony_ciconst _mockNpm = require('../../fixtures/mock-npm')
41cb0ef41Sopenharmony_ciconst { cleanCwd } = require('../../fixtures/clean-snapshot')
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_cit.cleanSnapshot = (str) => cleanCwd(str)
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst packument = spec => {
91cb0ef41Sopenharmony_ci  const mocks = {
101cb0ef41Sopenharmony_ci    cat: {
111cb0ef41Sopenharmony_ci      name: 'cat',
121cb0ef41Sopenharmony_ci      'dist-tags': {
131cb0ef41Sopenharmony_ci        latest: '1.0.1',
141cb0ef41Sopenharmony_ci      },
151cb0ef41Sopenharmony_ci      versions: {
161cb0ef41Sopenharmony_ci        '1.0.1': {
171cb0ef41Sopenharmony_ci          version: '1.0.1',
181cb0ef41Sopenharmony_ci          dependencies: {
191cb0ef41Sopenharmony_ci            dog: '2.0.0',
201cb0ef41Sopenharmony_ci          },
211cb0ef41Sopenharmony_ci        },
221cb0ef41Sopenharmony_ci      },
231cb0ef41Sopenharmony_ci    },
241cb0ef41Sopenharmony_ci    chai: {
251cb0ef41Sopenharmony_ci      name: 'chai',
261cb0ef41Sopenharmony_ci      'dist-tags': {
271cb0ef41Sopenharmony_ci        latest: '1.0.1',
281cb0ef41Sopenharmony_ci      },
291cb0ef41Sopenharmony_ci      versions: {
301cb0ef41Sopenharmony_ci        '1.0.1': {
311cb0ef41Sopenharmony_ci          version: '1.0.1',
321cb0ef41Sopenharmony_ci        },
331cb0ef41Sopenharmony_ci      },
341cb0ef41Sopenharmony_ci    },
351cb0ef41Sopenharmony_ci    dog: {
361cb0ef41Sopenharmony_ci      name: 'dog',
371cb0ef41Sopenharmony_ci      'dist-tags': {
381cb0ef41Sopenharmony_ci        latest: '2.0.0',
391cb0ef41Sopenharmony_ci      },
401cb0ef41Sopenharmony_ci      versions: {
411cb0ef41Sopenharmony_ci        '1.0.1': {
421cb0ef41Sopenharmony_ci          version: '1.0.1',
431cb0ef41Sopenharmony_ci        },
441cb0ef41Sopenharmony_ci        '2.0.0': {
451cb0ef41Sopenharmony_ci          version: '2.0.0',
461cb0ef41Sopenharmony_ci        },
471cb0ef41Sopenharmony_ci      },
481cb0ef41Sopenharmony_ci    },
491cb0ef41Sopenharmony_ci    theta: {
501cb0ef41Sopenharmony_ci      name: 'theta',
511cb0ef41Sopenharmony_ci      'dist-tags': {
521cb0ef41Sopenharmony_ci        latest: '1.0.1',
531cb0ef41Sopenharmony_ci      },
541cb0ef41Sopenharmony_ci      versions: {
551cb0ef41Sopenharmony_ci        '1.0.1': {
561cb0ef41Sopenharmony_ci          version: '1.0.1',
571cb0ef41Sopenharmony_ci        },
581cb0ef41Sopenharmony_ci      },
591cb0ef41Sopenharmony_ci    },
601cb0ef41Sopenharmony_ci  }
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ci  if (spec.name === 'eta') {
631cb0ef41Sopenharmony_ci    throw new Error('There is an error with this package.')
641cb0ef41Sopenharmony_ci  }
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ci  if (!mocks[spec.name]) {
671cb0ef41Sopenharmony_ci    const err = new Error()
681cb0ef41Sopenharmony_ci    err.code = 'E404'
691cb0ef41Sopenharmony_ci    throw err
701cb0ef41Sopenharmony_ci  }
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_ci  return mocks[spec.name]
731cb0ef41Sopenharmony_ci}
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ciconst fixtures = {
761cb0ef41Sopenharmony_ci  global: {
771cb0ef41Sopenharmony_ci    node_modules: {
781cb0ef41Sopenharmony_ci      cat: {
791cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
801cb0ef41Sopenharmony_ci          name: 'cat',
811cb0ef41Sopenharmony_ci          version: '1.0.0',
821cb0ef41Sopenharmony_ci        }, null, 2),
831cb0ef41Sopenharmony_ci      },
841cb0ef41Sopenharmony_ci    },
851cb0ef41Sopenharmony_ci  },
861cb0ef41Sopenharmony_ci  local: {
871cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
881cb0ef41Sopenharmony_ci      name: 'delta',
891cb0ef41Sopenharmony_ci      version: '1.0.0',
901cb0ef41Sopenharmony_ci      dependencies: {
911cb0ef41Sopenharmony_ci        cat: '^1.0.0',
921cb0ef41Sopenharmony_ci        dog: '^1.0.0',
931cb0ef41Sopenharmony_ci        theta: '^1.0.0',
941cb0ef41Sopenharmony_ci      },
951cb0ef41Sopenharmony_ci      devDependencies: {
961cb0ef41Sopenharmony_ci        zeta: '^1.0.0',
971cb0ef41Sopenharmony_ci      },
981cb0ef41Sopenharmony_ci      optionalDependencies: {
991cb0ef41Sopenharmony_ci        lorem: '^1.0.0',
1001cb0ef41Sopenharmony_ci      },
1011cb0ef41Sopenharmony_ci      peerDependencies: {
1021cb0ef41Sopenharmony_ci        chai: '^1.0.0',
1031cb0ef41Sopenharmony_ci      },
1041cb0ef41Sopenharmony_ci    }, null, 2),
1051cb0ef41Sopenharmony_ci    node_modules: {
1061cb0ef41Sopenharmony_ci      cat: {
1071cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1081cb0ef41Sopenharmony_ci          name: 'cat',
1091cb0ef41Sopenharmony_ci          version: '1.0.0',
1101cb0ef41Sopenharmony_ci          dependencies: {
1111cb0ef41Sopenharmony_ci            dog: '2.0.0',
1121cb0ef41Sopenharmony_ci          },
1131cb0ef41Sopenharmony_ci        }, null, 2),
1141cb0ef41Sopenharmony_ci        node_modules: {
1151cb0ef41Sopenharmony_ci          dog: {
1161cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
1171cb0ef41Sopenharmony_ci              name: 'dog',
1181cb0ef41Sopenharmony_ci              version: '2.0.0',
1191cb0ef41Sopenharmony_ci            }, null, 2),
1201cb0ef41Sopenharmony_ci          },
1211cb0ef41Sopenharmony_ci        },
1221cb0ef41Sopenharmony_ci      },
1231cb0ef41Sopenharmony_ci      chai: {
1241cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1251cb0ef41Sopenharmony_ci          name: 'chai',
1261cb0ef41Sopenharmony_ci          version: '1.0.0',
1271cb0ef41Sopenharmony_ci        }, null, 2),
1281cb0ef41Sopenharmony_ci      },
1291cb0ef41Sopenharmony_ci      dog: {
1301cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1311cb0ef41Sopenharmony_ci          name: 'dog',
1321cb0ef41Sopenharmony_ci          version: '1.0.1',
1331cb0ef41Sopenharmony_ci        }, null, 2),
1341cb0ef41Sopenharmony_ci      },
1351cb0ef41Sopenharmony_ci      zeta: {
1361cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1371cb0ef41Sopenharmony_ci          name: 'zeta',
1381cb0ef41Sopenharmony_ci          version: '1.0.0',
1391cb0ef41Sopenharmony_ci        }, null, 2),
1401cb0ef41Sopenharmony_ci      },
1411cb0ef41Sopenharmony_ci    },
1421cb0ef41Sopenharmony_ci  },
1431cb0ef41Sopenharmony_ci  workspaces: {
1441cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
1451cb0ef41Sopenharmony_ci      name: 'workspaces-project',
1461cb0ef41Sopenharmony_ci      version: '1.0.0',
1471cb0ef41Sopenharmony_ci      workspaces: ['packages/*'],
1481cb0ef41Sopenharmony_ci      dependencies: {
1491cb0ef41Sopenharmony_ci        dog: '^1.0.0',
1501cb0ef41Sopenharmony_ci      },
1511cb0ef41Sopenharmony_ci    }),
1521cb0ef41Sopenharmony_ci    node_modules: {
1531cb0ef41Sopenharmony_ci      a: t.fixture('symlink', '../packages/a'),
1541cb0ef41Sopenharmony_ci      b: t.fixture('symlink', '../packages/b'),
1551cb0ef41Sopenharmony_ci      c: t.fixture('symlink', '../packages/c'),
1561cb0ef41Sopenharmony_ci      cat: {
1571cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1581cb0ef41Sopenharmony_ci          name: 'cat',
1591cb0ef41Sopenharmony_ci          version: '1.0.0',
1601cb0ef41Sopenharmony_ci          dependencies: {
1611cb0ef41Sopenharmony_ci            dog: '2.0.0',
1621cb0ef41Sopenharmony_ci          },
1631cb0ef41Sopenharmony_ci        }),
1641cb0ef41Sopenharmony_ci        node_modules: {
1651cb0ef41Sopenharmony_ci          dog: {
1661cb0ef41Sopenharmony_ci            'package.json': JSON.stringify({
1671cb0ef41Sopenharmony_ci              name: 'dog',
1681cb0ef41Sopenharmony_ci              version: '2.0.0',
1691cb0ef41Sopenharmony_ci            }),
1701cb0ef41Sopenharmony_ci          },
1711cb0ef41Sopenharmony_ci        },
1721cb0ef41Sopenharmony_ci      },
1731cb0ef41Sopenharmony_ci      chai: {
1741cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1751cb0ef41Sopenharmony_ci          name: 'chai',
1761cb0ef41Sopenharmony_ci          version: '1.0.0',
1771cb0ef41Sopenharmony_ci        }),
1781cb0ef41Sopenharmony_ci      },
1791cb0ef41Sopenharmony_ci      dog: {
1801cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1811cb0ef41Sopenharmony_ci          name: 'dog',
1821cb0ef41Sopenharmony_ci          version: '1.0.1',
1831cb0ef41Sopenharmony_ci        }),
1841cb0ef41Sopenharmony_ci      },
1851cb0ef41Sopenharmony_ci      foo: {
1861cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1871cb0ef41Sopenharmony_ci          name: 'foo',
1881cb0ef41Sopenharmony_ci          version: '1.0.0',
1891cb0ef41Sopenharmony_ci          dependencies: {
1901cb0ef41Sopenharmony_ci            chai: '^1.0.0',
1911cb0ef41Sopenharmony_ci          },
1921cb0ef41Sopenharmony_ci        }),
1931cb0ef41Sopenharmony_ci      },
1941cb0ef41Sopenharmony_ci      zeta: {
1951cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
1961cb0ef41Sopenharmony_ci          name: 'zeta',
1971cb0ef41Sopenharmony_ci          version: '1.0.0',
1981cb0ef41Sopenharmony_ci        }),
1991cb0ef41Sopenharmony_ci      },
2001cb0ef41Sopenharmony_ci    },
2011cb0ef41Sopenharmony_ci    packages: {
2021cb0ef41Sopenharmony_ci      a: {
2031cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2041cb0ef41Sopenharmony_ci          name: 'a',
2051cb0ef41Sopenharmony_ci          version: '1.0.0',
2061cb0ef41Sopenharmony_ci          dependencies: {
2071cb0ef41Sopenharmony_ci            b: '^1.0.0',
2081cb0ef41Sopenharmony_ci            cat: '^1.0.0',
2091cb0ef41Sopenharmony_ci            foo: '^1.0.0',
2101cb0ef41Sopenharmony_ci          },
2111cb0ef41Sopenharmony_ci        }),
2121cb0ef41Sopenharmony_ci      },
2131cb0ef41Sopenharmony_ci      b: {
2141cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2151cb0ef41Sopenharmony_ci          name: 'b',
2161cb0ef41Sopenharmony_ci          version: '1.0.0',
2171cb0ef41Sopenharmony_ci          dependencies: {
2181cb0ef41Sopenharmony_ci            zeta: '^1.0.0',
2191cb0ef41Sopenharmony_ci          },
2201cb0ef41Sopenharmony_ci        }),
2211cb0ef41Sopenharmony_ci      },
2221cb0ef41Sopenharmony_ci      c: {
2231cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
2241cb0ef41Sopenharmony_ci          name: 'c',
2251cb0ef41Sopenharmony_ci          version: '1.0.0',
2261cb0ef41Sopenharmony_ci          dependencies: {
2271cb0ef41Sopenharmony_ci            theta: '^1.0.0',
2281cb0ef41Sopenharmony_ci          },
2291cb0ef41Sopenharmony_ci        }),
2301cb0ef41Sopenharmony_ci      },
2311cb0ef41Sopenharmony_ci    },
2321cb0ef41Sopenharmony_ci  },
2331cb0ef41Sopenharmony_ci}
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_ciconst mockNpm = async (t, { prefixDir, ...opts } = {}) => {
2361cb0ef41Sopenharmony_ci  const res = await _mockNpm(t, {
2371cb0ef41Sopenharmony_ci    command: 'outdated',
2381cb0ef41Sopenharmony_ci    mocks: {
2391cb0ef41Sopenharmony_ci      pacote: {
2401cb0ef41Sopenharmony_ci        packument,
2411cb0ef41Sopenharmony_ci      },
2421cb0ef41Sopenharmony_ci    },
2431cb0ef41Sopenharmony_ci    ...opts,
2441cb0ef41Sopenharmony_ci    prefixDir,
2451cb0ef41Sopenharmony_ci  })
2461cb0ef41Sopenharmony_ci
2471cb0ef41Sopenharmony_ci  // this is not currently used, but ensures that no requests are
2481cb0ef41Sopenharmony_ci  // hitting the registry.
2491cb0ef41Sopenharmony_ci  // XXX: the pacote mock should be replaced with mock registry calls
2501cb0ef41Sopenharmony_ci  const registry = new MockRegistry({
2511cb0ef41Sopenharmony_ci    tap: t,
2521cb0ef41Sopenharmony_ci    registry: res.npm.config.get('registry'),
2531cb0ef41Sopenharmony_ci    strict: true,
2541cb0ef41Sopenharmony_ci  })
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_ci  return {
2571cb0ef41Sopenharmony_ci    ...res,
2581cb0ef41Sopenharmony_ci    registry,
2591cb0ef41Sopenharmony_ci  }
2601cb0ef41Sopenharmony_ci}
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_cit.test('should display outdated deps', async t => {
2631cb0ef41Sopenharmony_ci  await t.test('outdated global', async t => {
2641cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
2651cb0ef41Sopenharmony_ci      globalPrefixDir: fixtures.global,
2661cb0ef41Sopenharmony_ci      config: { global: true },
2671cb0ef41Sopenharmony_ci    })
2681cb0ef41Sopenharmony_ci    await outdated.exec([])
2691cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
2701cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
2711cb0ef41Sopenharmony_ci  })
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_ci  await t.test('outdated', async t => {
2741cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
2751cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
2761cb0ef41Sopenharmony_ci      config: {
2771cb0ef41Sopenharmony_ci        color: 'always',
2781cb0ef41Sopenharmony_ci      },
2791cb0ef41Sopenharmony_ci    })
2801cb0ef41Sopenharmony_ci    await outdated.exec([])
2811cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
2821cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
2831cb0ef41Sopenharmony_ci  })
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ci  await t.test('outdated --omit=dev', async t => {
2861cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
2871cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
2881cb0ef41Sopenharmony_ci      config: {
2891cb0ef41Sopenharmony_ci        omit: ['dev'],
2901cb0ef41Sopenharmony_ci        color: 'always',
2911cb0ef41Sopenharmony_ci      },
2921cb0ef41Sopenharmony_ci    })
2931cb0ef41Sopenharmony_ci    await outdated.exec([])
2941cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
2951cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
2961cb0ef41Sopenharmony_ci  })
2971cb0ef41Sopenharmony_ci
2981cb0ef41Sopenharmony_ci  await t.test('outdated --omit=dev --omit=peer', async t => {
2991cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3001cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3011cb0ef41Sopenharmony_ci      config: {
3021cb0ef41Sopenharmony_ci        omit: ['dev', 'peer'],
3031cb0ef41Sopenharmony_ci        color: 'always',
3041cb0ef41Sopenharmony_ci      },
3051cb0ef41Sopenharmony_ci    })
3061cb0ef41Sopenharmony_ci    await outdated.exec([])
3071cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3081cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3091cb0ef41Sopenharmony_ci  })
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci  await t.test('outdated --omit=prod', async t => {
3121cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3131cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3141cb0ef41Sopenharmony_ci      config: {
3151cb0ef41Sopenharmony_ci        omit: ['prod'],
3161cb0ef41Sopenharmony_ci        color: 'always',
3171cb0ef41Sopenharmony_ci      },
3181cb0ef41Sopenharmony_ci    })
3191cb0ef41Sopenharmony_ci    await outdated.exec([])
3201cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3211cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3221cb0ef41Sopenharmony_ci  })
3231cb0ef41Sopenharmony_ci
3241cb0ef41Sopenharmony_ci  await t.test('outdated --long', async t => {
3251cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3261cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3271cb0ef41Sopenharmony_ci      config: {
3281cb0ef41Sopenharmony_ci        long: true,
3291cb0ef41Sopenharmony_ci      },
3301cb0ef41Sopenharmony_ci    })
3311cb0ef41Sopenharmony_ci    await outdated.exec([])
3321cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3331cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3341cb0ef41Sopenharmony_ci  })
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci  await t.test('outdated --json', async t => {
3371cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3381cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3391cb0ef41Sopenharmony_ci      config: {
3401cb0ef41Sopenharmony_ci        json: true,
3411cb0ef41Sopenharmony_ci      },
3421cb0ef41Sopenharmony_ci    })
3431cb0ef41Sopenharmony_ci    await outdated.exec([])
3441cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3451cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3461cb0ef41Sopenharmony_ci  })
3471cb0ef41Sopenharmony_ci
3481cb0ef41Sopenharmony_ci  await t.test('outdated --json --long', async t => {
3491cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3501cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3511cb0ef41Sopenharmony_ci      config: {
3521cb0ef41Sopenharmony_ci        json: true,
3531cb0ef41Sopenharmony_ci        long: true,
3541cb0ef41Sopenharmony_ci      },
3551cb0ef41Sopenharmony_ci    })
3561cb0ef41Sopenharmony_ci    await outdated.exec([])
3571cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3581cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3591cb0ef41Sopenharmony_ci  })
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci  await t.test('outdated --parseable', async t => {
3621cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3631cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3641cb0ef41Sopenharmony_ci      config: {
3651cb0ef41Sopenharmony_ci        parseable: true,
3661cb0ef41Sopenharmony_ci      },
3671cb0ef41Sopenharmony_ci    })
3681cb0ef41Sopenharmony_ci    await outdated.exec([])
3691cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3701cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3711cb0ef41Sopenharmony_ci  })
3721cb0ef41Sopenharmony_ci
3731cb0ef41Sopenharmony_ci  await t.test('outdated --parseable --long', async t => {
3741cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3751cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3761cb0ef41Sopenharmony_ci      config: {
3771cb0ef41Sopenharmony_ci        parseable: true,
3781cb0ef41Sopenharmony_ci        long: true,
3791cb0ef41Sopenharmony_ci      },
3801cb0ef41Sopenharmony_ci    })
3811cb0ef41Sopenharmony_ci    await outdated.exec([])
3821cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3831cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3841cb0ef41Sopenharmony_ci  })
3851cb0ef41Sopenharmony_ci
3861cb0ef41Sopenharmony_ci  await t.test('outdated --all', async t => {
3871cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
3881cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
3891cb0ef41Sopenharmony_ci      config: {
3901cb0ef41Sopenharmony_ci        all: true,
3911cb0ef41Sopenharmony_ci      },
3921cb0ef41Sopenharmony_ci    })
3931cb0ef41Sopenharmony_ci    await outdated.exec([])
3941cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
3951cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
3961cb0ef41Sopenharmony_ci  })
3971cb0ef41Sopenharmony_ci
3981cb0ef41Sopenharmony_ci  await t.test('outdated specific dep', async t => {
3991cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
4001cb0ef41Sopenharmony_ci      prefixDir: fixtures.local,
4011cb0ef41Sopenharmony_ci    })
4021cb0ef41Sopenharmony_ci    await outdated.exec(['cat'])
4031cb0ef41Sopenharmony_ci    t.equal(process.exitCode, 1)
4041cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput())
4051cb0ef41Sopenharmony_ci  })
4061cb0ef41Sopenharmony_ci})
4071cb0ef41Sopenharmony_ci
4081cb0ef41Sopenharmony_cit.test('should return if no outdated deps', async t => {
4091cb0ef41Sopenharmony_ci  const testDir = {
4101cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
4111cb0ef41Sopenharmony_ci      name: 'delta',
4121cb0ef41Sopenharmony_ci      version: '1.0.0',
4131cb0ef41Sopenharmony_ci      dependencies: {
4141cb0ef41Sopenharmony_ci        cat: '^1.0.0',
4151cb0ef41Sopenharmony_ci      },
4161cb0ef41Sopenharmony_ci    }, null, 2),
4171cb0ef41Sopenharmony_ci    node_modules: {
4181cb0ef41Sopenharmony_ci      cat: {
4191cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4201cb0ef41Sopenharmony_ci          name: 'cat',
4211cb0ef41Sopenharmony_ci          version: '1.0.1',
4221cb0ef41Sopenharmony_ci        }, null, 2),
4231cb0ef41Sopenharmony_ci      },
4241cb0ef41Sopenharmony_ci    },
4251cb0ef41Sopenharmony_ci  }
4261cb0ef41Sopenharmony_ci
4271cb0ef41Sopenharmony_ci  const { outdated, joinedOutput } = await mockNpm(t, {
4281cb0ef41Sopenharmony_ci    prefixDir: testDir,
4291cb0ef41Sopenharmony_ci
4301cb0ef41Sopenharmony_ci  })
4311cb0ef41Sopenharmony_ci  await outdated.exec([])
4321cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '', 'no logs')
4331cb0ef41Sopenharmony_ci})
4341cb0ef41Sopenharmony_ci
4351cb0ef41Sopenharmony_cit.test('throws if error with a dep', async t => {
4361cb0ef41Sopenharmony_ci  const testDir = {
4371cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
4381cb0ef41Sopenharmony_ci      name: 'delta',
4391cb0ef41Sopenharmony_ci      version: '1.0.0',
4401cb0ef41Sopenharmony_ci      dependencies: {
4411cb0ef41Sopenharmony_ci        eta: '^1.0.0',
4421cb0ef41Sopenharmony_ci      },
4431cb0ef41Sopenharmony_ci    }, null, 2),
4441cb0ef41Sopenharmony_ci    node_modules: {
4451cb0ef41Sopenharmony_ci      eta: {
4461cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4471cb0ef41Sopenharmony_ci          name: 'eta',
4481cb0ef41Sopenharmony_ci          version: '1.0.1',
4491cb0ef41Sopenharmony_ci        }, null, 2),
4501cb0ef41Sopenharmony_ci      },
4511cb0ef41Sopenharmony_ci    },
4521cb0ef41Sopenharmony_ci  }
4531cb0ef41Sopenharmony_ci
4541cb0ef41Sopenharmony_ci  const { outdated } = await mockNpm(t, {
4551cb0ef41Sopenharmony_ci    prefixDir: testDir,
4561cb0ef41Sopenharmony_ci  })
4571cb0ef41Sopenharmony_ci
4581cb0ef41Sopenharmony_ci  await t.rejects(outdated.exec([]), 'There is an error with this package.')
4591cb0ef41Sopenharmony_ci})
4601cb0ef41Sopenharmony_ci
4611cb0ef41Sopenharmony_cit.test('should skip missing non-prod deps', async t => {
4621cb0ef41Sopenharmony_ci  const testDir = {
4631cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
4641cb0ef41Sopenharmony_ci      name: 'delta',
4651cb0ef41Sopenharmony_ci      version: '1.0.0',
4661cb0ef41Sopenharmony_ci      devDependencies: {
4671cb0ef41Sopenharmony_ci        chai: '^1.0.0',
4681cb0ef41Sopenharmony_ci      },
4691cb0ef41Sopenharmony_ci    }, null, 2),
4701cb0ef41Sopenharmony_ci    node_modules: {},
4711cb0ef41Sopenharmony_ci  }
4721cb0ef41Sopenharmony_ci
4731cb0ef41Sopenharmony_ci  const { outdated, joinedOutput } = await mockNpm(t, {
4741cb0ef41Sopenharmony_ci    prefixDir: testDir,
4751cb0ef41Sopenharmony_ci  })
4761cb0ef41Sopenharmony_ci
4771cb0ef41Sopenharmony_ci  await outdated.exec([])
4781cb0ef41Sopenharmony_ci
4791cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '', 'no logs')
4801cb0ef41Sopenharmony_ci})
4811cb0ef41Sopenharmony_ci
4821cb0ef41Sopenharmony_cit.test('should skip invalid pkg ranges', async t => {
4831cb0ef41Sopenharmony_ci  const testDir = {
4841cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
4851cb0ef41Sopenharmony_ci      name: 'delta',
4861cb0ef41Sopenharmony_ci      version: '1.0.0',
4871cb0ef41Sopenharmony_ci      dependencies: {
4881cb0ef41Sopenharmony_ci        cat: '>=^2',
4891cb0ef41Sopenharmony_ci      },
4901cb0ef41Sopenharmony_ci    }, null, 2),
4911cb0ef41Sopenharmony_ci    node_modules: {
4921cb0ef41Sopenharmony_ci      cat: {
4931cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
4941cb0ef41Sopenharmony_ci          name: 'cat',
4951cb0ef41Sopenharmony_ci          version: '1.0.0',
4961cb0ef41Sopenharmony_ci        }, null, 2),
4971cb0ef41Sopenharmony_ci      },
4981cb0ef41Sopenharmony_ci    },
4991cb0ef41Sopenharmony_ci  }
5001cb0ef41Sopenharmony_ci
5011cb0ef41Sopenharmony_ci  const { outdated, joinedOutput } = await mockNpm(t, {
5021cb0ef41Sopenharmony_ci    prefixDir: testDir,
5031cb0ef41Sopenharmony_ci  })
5041cb0ef41Sopenharmony_ci  await outdated.exec([])
5051cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '', 'no logs')
5061cb0ef41Sopenharmony_ci})
5071cb0ef41Sopenharmony_ci
5081cb0ef41Sopenharmony_cit.test('should skip git specs', async t => {
5091cb0ef41Sopenharmony_ci  const testDir = {
5101cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
5111cb0ef41Sopenharmony_ci      name: 'delta',
5121cb0ef41Sopenharmony_ci      version: '1.0.0',
5131cb0ef41Sopenharmony_ci      dependencies: {
5141cb0ef41Sopenharmony_ci        cat: 'github:username/foo',
5151cb0ef41Sopenharmony_ci      },
5161cb0ef41Sopenharmony_ci    }, null, 2),
5171cb0ef41Sopenharmony_ci    node_modules: {
5181cb0ef41Sopenharmony_ci      cat: {
5191cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
5201cb0ef41Sopenharmony_ci          name: 'cat',
5211cb0ef41Sopenharmony_ci          version: '1.0.0',
5221cb0ef41Sopenharmony_ci        }, null, 2),
5231cb0ef41Sopenharmony_ci      },
5241cb0ef41Sopenharmony_ci    },
5251cb0ef41Sopenharmony_ci  }
5261cb0ef41Sopenharmony_ci
5271cb0ef41Sopenharmony_ci  const { outdated, joinedOutput } = await mockNpm(t, {
5281cb0ef41Sopenharmony_ci    prefixDir: testDir,
5291cb0ef41Sopenharmony_ci  })
5301cb0ef41Sopenharmony_ci  await outdated.exec([])
5311cb0ef41Sopenharmony_ci  t.equal(joinedOutput(), '', 'no logs')
5321cb0ef41Sopenharmony_ci})
5331cb0ef41Sopenharmony_ci
5341cb0ef41Sopenharmony_cit.test('workspaces', async t => {
5351cb0ef41Sopenharmony_ci  const mockWorkspaces = async (t, { exitCode = 1, ...config } = {}) => {
5361cb0ef41Sopenharmony_ci    const { outdated, joinedOutput } = await mockNpm(t, {
5371cb0ef41Sopenharmony_ci      prefixDir: fixtures.workspaces,
5381cb0ef41Sopenharmony_ci      config,
5391cb0ef41Sopenharmony_ci    })
5401cb0ef41Sopenharmony_ci
5411cb0ef41Sopenharmony_ci    await outdated.exec([])
5421cb0ef41Sopenharmony_ci
5431cb0ef41Sopenharmony_ci    t.matchSnapshot(joinedOutput(), 'output')
5441cb0ef41Sopenharmony_ci    t.equal(process.exitCode, exitCode ?? undefined)
5451cb0ef41Sopenharmony_ci  }
5461cb0ef41Sopenharmony_ci
5471cb0ef41Sopenharmony_ci  await t.test('should display ws outdated deps human output', t =>
5481cb0ef41Sopenharmony_ci    mockWorkspaces(t))
5491cb0ef41Sopenharmony_ci
5501cb0ef41Sopenharmony_ci  // TODO: This should display dog, but doesn't because arborist filters
5511cb0ef41Sopenharmony_ci  // workspace deps even if they're also root deps
5521cb0ef41Sopenharmony_ci  // This will be fixed in a future arborist version
5531cb0ef41Sopenharmony_ci  await t.test('should display only root outdated when ws disabled', t =>
5541cb0ef41Sopenharmony_ci    mockWorkspaces(t, { workspaces: false, exitCode: null }))
5551cb0ef41Sopenharmony_ci
5561cb0ef41Sopenharmony_ci  await t.test('should display ws outdated deps json output', t =>
5571cb0ef41Sopenharmony_ci    mockWorkspaces(t, { json: true }))
5581cb0ef41Sopenharmony_ci
5591cb0ef41Sopenharmony_ci  await t.test('should display ws outdated deps parseable output', t =>
5601cb0ef41Sopenharmony_ci    mockWorkspaces(t, { parseable: true }))
5611cb0ef41Sopenharmony_ci
5621cb0ef41Sopenharmony_ci  await t.test('should display all dependencies', t =>
5631cb0ef41Sopenharmony_ci    mockWorkspaces(t, { all: true }))
5641cb0ef41Sopenharmony_ci
5651cb0ef41Sopenharmony_ci  await t.test('should highlight ws in dependend by section', t =>
5661cb0ef41Sopenharmony_ci    mockWorkspaces(t, { color: 'always' }))
5671cb0ef41Sopenharmony_ci
5681cb0ef41Sopenharmony_ci  await t.test('should display results filtered by ws', t =>
5691cb0ef41Sopenharmony_ci    mockWorkspaces(t, { workspace: 'a' }))
5701cb0ef41Sopenharmony_ci
5711cb0ef41Sopenharmony_ci  await t.test('should display json results filtered by ws', t =>
5721cb0ef41Sopenharmony_ci    mockWorkspaces(t, { json: true, workspace: 'a' }))
5731cb0ef41Sopenharmony_ci
5741cb0ef41Sopenharmony_ci  await t.test('should display parseable results filtered by ws', t =>
5751cb0ef41Sopenharmony_ci    mockWorkspaces(t, { parseable: true, workspace: 'a' }))
5761cb0ef41Sopenharmony_ci
5771cb0ef41Sopenharmony_ci  await t.test('should display nested deps when filtering by ws and using --all', t =>
5781cb0ef41Sopenharmony_ci    mockWorkspaces(t, { all: true, workspace: 'a' }))
5791cb0ef41Sopenharmony_ci
5801cb0ef41Sopenharmony_ci  await t.test('should display no results if ws has no deps to display', t =>
5811cb0ef41Sopenharmony_ci    mockWorkspaces(t, { workspace: 'b', exitCode: null }))
5821cb0ef41Sopenharmony_ci
5831cb0ef41Sopenharmony_ci  await t.test('should display missing deps when filtering by ws', t =>
5841cb0ef41Sopenharmony_ci    mockWorkspaces(t, { workspace: 'c', exitCode: 1 }))
5851cb0ef41Sopenharmony_ci})
5861cb0ef41Sopenharmony_ci
5871cb0ef41Sopenharmony_cit.test('aliases', async t => {
5881cb0ef41Sopenharmony_ci  const testDir = {
5891cb0ef41Sopenharmony_ci    'package.json': JSON.stringify({
5901cb0ef41Sopenharmony_ci      name: 'display-aliases',
5911cb0ef41Sopenharmony_ci      version: '1.0.0',
5921cb0ef41Sopenharmony_ci      dependencies: {
5931cb0ef41Sopenharmony_ci        cat: 'npm:dog@latest',
5941cb0ef41Sopenharmony_ci      },
5951cb0ef41Sopenharmony_ci    }),
5961cb0ef41Sopenharmony_ci    node_modules: {
5971cb0ef41Sopenharmony_ci      cat: {
5981cb0ef41Sopenharmony_ci        'package.json': JSON.stringify({
5991cb0ef41Sopenharmony_ci          name: 'dog',
6001cb0ef41Sopenharmony_ci          version: '1.0.0',
6011cb0ef41Sopenharmony_ci        }),
6021cb0ef41Sopenharmony_ci      },
6031cb0ef41Sopenharmony_ci    },
6041cb0ef41Sopenharmony_ci  }
6051cb0ef41Sopenharmony_ci
6061cb0ef41Sopenharmony_ci  const { outdated, joinedOutput } = await mockNpm(t, {
6071cb0ef41Sopenharmony_ci    prefixDir: testDir,
6081cb0ef41Sopenharmony_ci  })
6091cb0ef41Sopenharmony_ci  await outdated.exec([])
6101cb0ef41Sopenharmony_ci
6111cb0ef41Sopenharmony_ci  t.matchSnapshot(joinedOutput(), 'should display aliased outdated dep output')
6121cb0ef41Sopenharmony_ci  t.equal(process.exitCode, 1)
6131cb0ef41Sopenharmony_ci})
614