diff options
author | isaacs <i@izs.me> | 2021-05-07 02:06:29 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-05-10 19:37:12 +0300 |
commit | 1d092144eaaabff63ac8424b40b2286822be7677 (patch) | |
tree | cfc63a6d91736f3165fcc4d38431ff3a2819b660 /test | |
parent | 1eb7e5c7d466293b472c2506c64e5a89ec84ac2f (diff) |
fix(packages): locale-agnostic string sorting
This adds the 'en' locale to all instances of String.localeCompare
within the CLI codebase.
Tests added for the cases where we're sorting arbitrary user-generated
data. The tests rely on the fact that 'ch' sorts after 'd' in the
`'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that
this is the default behavior if no locale is specified, `LC_ALL=sk` is
set in the test environment.
Other instances of `localeCompare` sort data that the cli controls, so
no tests were added.
Re: https://github.com/npm/cli/issues/2829
PR-URL: https://github.com/npm/cli/pull/3203
Credit: @isaacs
Close: #3203
Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/config.js | 6 | ||||
-rw-r--r-- | test/lib/exec.js | 8 | ||||
-rw-r--r-- | test/lib/link.js | 2 | ||||
-rw-r--r-- | test/lib/load-all-commands.js | 2 | ||||
-rw-r--r-- | test/lib/ls.js | 262 | ||||
-rw-r--r-- | test/lib/outdated.js | 64 | ||||
-rw-r--r-- | test/lib/utils/cleanup-log-files.js | 2 | ||||
-rw-r--r-- | test/lib/utils/completion/installed-deep.js | 19 | ||||
-rw-r--r-- | test/lib/utils/tar.js | 3 |
9 files changed, 193 insertions, 175 deletions
diff --git a/test/lib/config.js b/test/lib/config.js index 155ad0bcf..6c0429313 100644 --- a/test/lib/config.js +++ b/test/lib/config.js @@ -49,6 +49,9 @@ const cliConfig = { json: false, long: false, global: false, + cat: true, + chai: true, + dog: true, } const npm = { @@ -197,6 +200,9 @@ t.test('config list --json', t => { json: true, long: false, global: false, + cat: true, + chai: true, + dog: true, }, 'should list configs usin json' ) diff --git a/test/lib/exec.js b/test/lib/exec.js index 3d2da32a7..33e30e24f 100644 --- a/test/lib/exec.js +++ b/test/lib/exec.js @@ -601,7 +601,7 @@ t.test('run command with 2 packages, need install, verify sort', t => { for (const packages of cases) { t.test(packages.join(', '), t => { config.package = packages - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -756,7 +756,7 @@ t.test('prompt when installs are needed if not already present and shell is a TT config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -825,7 +825,7 @@ t.test('skip prompt when installs are needed if not already present and shell is config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/07de77790e5f40f2') npm.localPrefix = path @@ -892,7 +892,7 @@ t.test('skip prompt when installs are needed if not already present and shell is config.package = packages config.yes = undefined - const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b)) + const add = packages.map(p => `${p}@`).sort((a, b) => a.localeCompare(b, 'en')) const path = t.testdir() const installDir = resolve('cache-dir/_npx/f7fbba6e0636f890') npm.localPrefix = path diff --git a/test/lib/link.js b/test/lib/link.js index 34c533fb7..d3e661852 100644 --- a/test/lib/link.js +++ b/test/lib/link.js @@ -27,7 +27,7 @@ const printLinks = async (opts) => { const arb = new Arborist(opts) const tree = await arb.loadActual() const linkedItems = [...tree.inventory.values()] - .sort((a, b) => a.pkgid.localeCompare(b.pkgid)) + .sort((a, b) => a.pkgid.localeCompare(b.pkgid, 'en')) for (const item of linkedItems) { if (item.target) res += `${item.path} -> ${item.target.path}\n` diff --git a/test/lib/load-all-commands.js b/test/lib/load-all-commands.js index 8267cd543..935019756 100644 --- a/test/lib/load-all-commands.js +++ b/test/lib/load-all-commands.js @@ -15,7 +15,7 @@ t.test('load each command', t => { npm.load((er) => { t.notOk(er) npm.config.set('usage', true) - for (const cmd of cmdList.sort((a, b) => a.localeCompare(b))) { + for (const cmd of cmdList.sort((a, b) => a.localeCompare(b, 'en'))) { t.test(cmd, t => { const impl = npm.commands[cmd] if (impl.completion) diff --git a/test/lib/ls.js b/test/lib/ls.js index 6eeaf0ad6..276a06180 100644 --- a/test/lib/ls.js +++ b/test/lib/ls.js @@ -21,19 +21,19 @@ const simpleNmFixture = { name: 'foo', version: '1.0.0', dependencies: { - bar: '^1.0.0', + dog: '^1.0.0', }, }), }, - bar: { + dog: { 'package.json': JSON.stringify({ - name: 'bar', + name: 'dog', version: '1.0.0', }), }, - lorem: { + chai: { 'package.json': JSON.stringify({ - name: 'lorem', + name: 'chai', version: '1.0.0', }), }, @@ -58,13 +58,13 @@ const diffDepTypesNmFixture = { description: 'A PROD dep kind of dep', version: '1.0.0', dependencies: { - bar: '^2.0.0', + dog: '^2.0.0', }, }), node_modules: { - bar: { + dog: { 'package.json': JSON.stringify({ - name: 'bar', + name: 'dog', description: 'A dep that bars', version: '2.0.0', }), @@ -132,7 +132,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -181,12 +181,12 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of filtered by package and colored output') npm.color = false @@ -224,12 +224,12 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of filtered package and its ancestors') t.end() @@ -243,7 +243,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -257,7 +257,7 @@ t.test('ls', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output tree contaning only occurrences of multiple filtered packages and their ancestors') t.end() @@ -271,7 +271,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -298,7 +298,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -321,7 +321,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -412,9 +412,9 @@ t.test('ls', (t) => { t.equal(err.code, 'ELSPROBLEMS', 'should have error code') t.equal( redactCwd(err.message).replace(/\r\n/g, '\n'), + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/chai\n' + 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/foo\n' + - 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0\n' + - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls-missing-invalid-extraneous/node_modules/lorem', + 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0', 'should log missing/invalid/extraneous errors' ) t.matchSnapshot(redactCwd(result), 'should output tree containing missing, invalid, extraneous labels') @@ -451,7 +451,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -480,7 +480,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -509,7 +509,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -584,7 +584,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -613,7 +613,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -642,7 +642,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -673,7 +673,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -723,7 +723,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -835,7 +835,7 @@ t.test('ls', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1243,7 +1243,7 @@ t.test('ls', (t) => { dependencies: { a: { version: '1.0.1', - resolved: 'foo@bar://b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c', + resolved: 'foo@dog://b8f3a2fc0c3bb8ffd8b0d0072cc6b5a3667e963c', integrity: 'sha512-8AN9lNCcBt5Xeje7fMEEpp5K3rgcAzIpTtAjYb/YMUYu8SbIVF6wz0WqACDVKvpQOUcSfNHZQNLNmue0QSwXOQ==', }, }, @@ -1544,7 +1544,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1592,12 +1592,12 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of filtered by package') t.end() @@ -1611,12 +1611,12 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of filtered package') t.end() @@ -1630,7 +1630,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -1644,7 +1644,7 @@ t.test('ls --parseable', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.matchSnapshot(redactCwd(result), 'should output parseable contaning only occurrences of multiple filtered packages and their ancestors') t.end() @@ -1658,7 +1658,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1685,7 +1685,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1708,7 +1708,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1731,7 +1731,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -1772,7 +1772,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1801,7 +1801,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1830,7 +1830,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -1869,7 +1869,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1898,7 +1898,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1927,7 +1927,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -1995,7 +1995,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -2037,7 +2037,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2087,7 +2087,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2114,7 +2114,7 @@ t.test('ls --parseable', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2463,7 +2463,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2479,12 +2479,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2505,16 +2505,16 @@ t.test('ls --json', (t) => { jsonParse(result), { problems: [ - 'extraneous: bar@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/bar', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/chai', + 'extraneous: dog@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/dog', 'extraneous: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/foo', - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/lorem', ], dependencies: { - bar: { + dog: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: bar@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/bar', + 'extraneous: dog@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/dog', ], }, foo: { @@ -2524,16 +2524,16 @@ t.test('ls --json', (t) => { 'extraneous: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/foo', ], dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-package.json/node_modules/chai', ], }, }, @@ -2563,22 +2563,22 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/chai', ], dependencies: { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-extraneous-deps/node_modules/chai', ], }, }, @@ -2597,8 +2597,8 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - bar: '^1.0.0', - lorem: '^1.0.0', + dog: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -2638,12 +2638,12 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['lorem'], (err) => { + ls.exec(['chai'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2651,7 +2651,7 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { + chai: { version: '1.0.0', }, }, @@ -2674,12 +2674,12 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, }) - ls.exec(['bar'], (err) => { + ls.exec(['dog'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2690,7 +2690,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, @@ -2710,7 +2710,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', ipsum: '^1.0.0', }, }), @@ -2724,7 +2724,7 @@ t.test('ls --json', (t) => { }, }, }) - ls.exec(['bar@*', 'lorem@1.0.0'], (err) => { + ls.exec(['dog@*', 'chai@1.0.0'], (err) => { t.error(err, 'npm ls') t.same( jsonParse(result), @@ -2735,12 +2735,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2758,7 +2758,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2792,7 +2792,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2808,7 +2808,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2830,7 +2830,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2846,7 +2846,7 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2868,7 +2868,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { foo: '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, }), ...simpleNmFixture, @@ -2884,12 +2884,12 @@ t.test('ls --json', (t) => { foo: { version: '1.0.0', dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', }, }, @@ -2922,9 +2922,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', problems: [ + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/chai', 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/foo', 'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0', - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/lorem', ], dependencies: { foo: { @@ -2934,16 +2934,16 @@ t.test('ls --json', (t) => { 'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/foo', ], dependencies: { - bar: { + dog: { version: '1.0.0', }, }, }, - lorem: { + chai: { version: '1.0.0', extraneous: true, problems: [ - 'extraneous: lorem@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/lorem', + 'extraneous: chai@1.0.0 {CWD}/tap-testdir-ls-ls---json-missing-invalid-extraneous/node_modules/chai', ], }, ipsum: { @@ -2969,7 +2969,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -2995,7 +2995,7 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, @@ -3016,7 +3016,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3042,7 +3042,7 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, @@ -3063,7 +3063,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', 'linked-dep': '^1.0.0', }, devDependencies: { @@ -3115,7 +3115,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3136,9 +3136,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json containing production deps' @@ -3156,7 +3156,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3177,9 +3177,9 @@ t.test('ls --json', (t) => { name: 'test-npm-ls', version: '1.0.0', dependencies: { - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json containing only prod deps' @@ -3326,7 +3326,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3367,21 +3367,21 @@ t.test('ls --json', (t) => { name: 'foo', version: '1.0.0', dependencies: { - bar: { - name: 'bar', + dog: { + name: 'dog', version: '1.0.0', - _id: 'bar@1.0.0', + _id: 'dog@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/bar', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/dog', extraneous: false, }, }, _id: 'foo@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^1.0.0' }, + _dependencies: { dog: '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/foo', extraneous: false, }, @@ -3393,14 +3393,14 @@ t.test('ls --json', (t) => { path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/dev-dep', extraneous: false, }, - lorem: { - name: 'lorem', + chai: { + name: 'chai', version: '1.0.0', - _id: 'lorem@1.0.0', + _id: 'chai@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/lorem', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/chai', extraneous: false, }, 'optional-dep': { @@ -3419,22 +3419,22 @@ t.test('ls --json', (t) => { description: 'A PROD dep kind of dep', version: '1.0.0', dependencies: { - bar: { - name: 'bar', + dog: { + name: 'dog', description: 'A dep that bars', version: '2.0.0', - _id: 'bar@2.0.0', + _id: 'dog@2.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep/node_modules/bar', + path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep/node_modules/dog', extraneous: false, }, }, _id: 'prod-dep@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^2.0.0' }, + _dependencies: { dog: '^2.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long/node_modules/prod-dep', extraneous: false, }, @@ -3443,7 +3443,7 @@ t.test('ls --json', (t) => { optionalDependencies: { 'optional-dep': '^1.0.0' }, peerDependencies: { 'peer-dep': '^1.0.0' }, _id: 'test-npm-ls@1.0.0', - _dependencies: { 'prod-dep': '^1.0.0', lorem: '^1.0.0', 'optional-dep': '^1.0.0' }, + _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long', extraneous: false, }, @@ -3464,7 +3464,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3507,14 +3507,14 @@ t.test('ls --json', (t) => { path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/dev-dep', extraneous: false, }, - lorem: { - name: 'lorem', + chai: { + name: 'chai', version: '1.0.0', - _id: 'lorem@1.0.0', + _id: 'chai@1.0.0', devDependencies: {}, peerDependencies: {}, _dependencies: {}, - path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/lorem', + path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/chai', extraneous: false, }, 'optional-dep': { @@ -3535,7 +3535,7 @@ t.test('ls --json', (t) => { _id: 'prod-dep@1.0.0', devDependencies: {}, peerDependencies: {}, - _dependencies: { bar: '^2.0.0' }, + _dependencies: { dog: '^2.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0/node_modules/prod-dep', extraneous: false, }, @@ -3544,7 +3544,7 @@ t.test('ls --json', (t) => { optionalDependencies: { 'optional-dep': '^1.0.0' }, peerDependencies: { 'peer-dep': '^1.0.0' }, _id: 'test-npm-ls@1.0.0', - _dependencies: { 'prod-dep': '^1.0.0', lorem: '^1.0.0', 'optional-dep': '^1.0.0' }, + _dependencies: { 'prod-dep': '^1.0.0', chai: '^1.0.0', 'optional-dep': '^1.0.0' }, path: '{CWD}/tap-testdir-ls-ls---json---long---depth-0', extraneous: false, }, @@ -3598,7 +3598,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3635,13 +3635,13 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, - lorem: { version: '1.0.0' }, + chai: { version: '1.0.0' }, 'optional-dep': { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, }, }, 'should output json signaling missing peer dep in problems' @@ -3657,7 +3657,7 @@ t.test('ls --json', (t) => { version: '1.0.0', dependencies: { 'prod-dep': '^1.0.0', - lorem: '^1.0.0', + chai: '^1.0.0', }, devDependencies: { 'dev-dep': '^1.0.0', @@ -3699,12 +3699,12 @@ t.test('ls --json', (t) => { dependencies: { foo: { version: '1.0.0', - dependencies: { bar: { version: '1.0.0' } }, + dependencies: { dog: { version: '1.0.0' } }, }, }, }, - lorem: { version: '1.0.0' }, - 'prod-dep': { version: '1.0.0', dependencies: { bar: { version: '2.0.0' } } }, + chai: { version: '1.0.0' }, + 'prod-dep': { version: '1.0.0', dependencies: { dog: { version: '2.0.0' } } }, 'missing-optional-dep': {}, // missing optional dep has an empty entry in json output }, }, diff --git a/test/lib/outdated.js b/test/lib/outdated.js index 605853056..f7d572821 100644 --- a/test/lib/outdated.js +++ b/test/lib/outdated.js @@ -3,8 +3,8 @@ const mockNpm = require('../fixtures/mock-npm') const packument = spec => { const mocks = { - alpha: { - name: 'alpha', + cat: { + name: 'cat', 'dist-tags': { latest: '1.0.1', }, @@ -12,13 +12,13 @@ const packument = spec => { '1.0.1': { version: '1.0.1', dependencies: { - gamma: '2.0.0', + dog: '2.0.0', }, }, }, }, - beta: { - name: 'beta', + chai: { + name: 'chai', 'dist-tags': { latest: '1.0.1', }, @@ -28,8 +28,8 @@ const packument = spec => { }, }, }, - gamma: { - name: 'gamma', + dog: { + name: 'dog', 'dist-tags': { latest: '2.0.0', }, @@ -74,9 +74,9 @@ const output = (msg) => { const globalDir = t.testdir({ node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, @@ -116,8 +116,8 @@ t.test('should display outdated deps', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '^1.0.0', - gamma: '^1.0.0', + cat: '^1.0.0', + dog: '^1.0.0', theta: '^1.0.0', }, devDependencies: { @@ -127,36 +127,36 @@ t.test('should display outdated deps', t => { lorem: '^1.0.0', }, peerDependencies: { - beta: '^1.0.0', + chai: '^1.0.0', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', dependencies: { - gamma: '2.0.0', + dog: '2.0.0', }, }, null, 2), node_modules: { - gamma: { + dog: { 'package.json': JSON.stringify({ - name: 'gamma', + name: 'dog', version: '2.0.0', }, null, 2), }, }, }, - beta: { + chai: { 'package.json': JSON.stringify({ - name: 'beta', + name: 'chai', version: '1.0.0', }, null, 2), }, - gamma: { + dog: { 'package.json': JSON.stringify({ - name: 'gamma', + name: 'dog', version: '1.0.1', }, null, 2), }, @@ -307,7 +307,7 @@ t.test('should display outdated deps', t => { config: { global: false, }, - }).exec(['alpha'], () => { + }).exec(['cat'], () => { t.matchSnapshot(logs) t.end() }) @@ -322,13 +322,13 @@ t.test('should return if no outdated deps', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '^1.0.0', + cat: '^1.0.0', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.1', }, null, 2), }, @@ -376,7 +376,7 @@ t.test('should skip missing non-prod deps', t => { name: 'delta', version: '1.0.0', devDependencies: { - beta: '^1.0.0', + chai: '^1.0.0', }, }, null, 2), node_modules: {}, @@ -396,13 +396,13 @@ t.test('should skip invalid pkg ranges', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: '>=^2', + cat: '>=^2', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, @@ -421,13 +421,13 @@ t.test('should skip git specs', t => { name: 'delta', version: '1.0.0', dependencies: { - alpha: 'github:username/foo', + cat: 'github:username/foo', }, }, null, 2), node_modules: { - alpha: { + cat: { 'package.json': JSON.stringify({ - name: 'alpha', + name: 'cat', version: '1.0.0', }, null, 2), }, diff --git a/test/lib/utils/cleanup-log-files.js b/test/lib/utils/cleanup-log-files.js index 61240b7b5..e97cf36b5 100644 --- a/test/lib/utils/cleanup-log-files.js +++ b/test/lib/utils/cleanup-log-files.js @@ -71,7 +71,7 @@ t.test('rimraf fail', t => { const warnings = [] const warn = (...warning) => warnings.push(basename(warning[2])) return cleanup(cache, 3, warn).then(() => { - t.strictSame(warnings.sort((a, b) => a.localeCompare(b)), [ + t.strictSame(warnings.sort((a, b) => a.localeCompare(b, 'en')), [ '1-debug.log', '2-debug.log', ]) diff --git a/test/lib/utils/completion/installed-deep.js b/test/lib/utils/completion/installed-deep.js index ba14798bb..21e77a568 100644 --- a/test/lib/utils/completion/installed-deep.js +++ b/test/lib/utils/completion/installed-deep.js @@ -63,6 +63,15 @@ const fixture = { 'package.json': JSON.stringify({ name: 'c', version: '1.0.0', + dependencies: { + ch: '1.0.0', + }, + }), + }, + ch: { + 'package.json': JSON.stringify({ + name: 'ch', + version: '1.0.0', }), }, d: { @@ -160,8 +169,8 @@ t.test('get list of package names', async t => { ['foo', '-g'], ['a-bar', '-g'], 'a', 'b', 'c', - 'd', 'e', 'f', - 'g', 'bb', + 'ch', 'd', 'e', + 'f', 'g', 'bb', ], 'should return list of package names and global flag' ) @@ -211,9 +220,9 @@ t.test('limit depth', async t => { ['bar', '-g'], ['foo', '-g'], 'a', 'b', - 'c', 'd', - 'e', 'f', - 'g', + 'c', 'ch', + 'd', 'e', + 'f', 'g', ], 'should print only packages up to the specified depth' ) diff --git a/test/lib/utils/tar.js b/test/lib/utils/tar.js index 5758442fc..2662d47ac 100644 --- a/test/lib/utils/tar.js +++ b/test/lib/utils/tar.js @@ -26,6 +26,9 @@ t.test('should log tarball contents', async (t) => { 'bundle-dep', ], }, null, 2), + cat: 'meow', + chai: 'blub', + dog: 'woof', node_modules: { 'bundle-dep': 'toto', }, |