summaryrefslogtreecommitdiff
path: root/deps/npm/test/lib/utils
diff options
context:
space:
mode:
authornpm CLI robot <npm-cli+bot@github.com>2022-11-07 13:02:05 -0500
committerGitHub <noreply@github.com>2022-11-07 18:02:05 +0000
commit14a9f77c7cf4d52ed222c156069f63a599f9004b (patch)
tree7f734aa6c0dcb60236161ef8708f6ecc16f450f1 /deps/npm/test/lib/utils
parent06603c44a5b0e92b1a3591ace467ce9770bf9658 (diff)
downloadnode-new-14a9f77c7cf4d52ed222c156069f63a599f9004b.tar.gz
deps: upgrade npm to 8.19.3
PR-URL: https://github.com/nodejs/node/pull/45322 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'deps/npm/test/lib/utils')
-rw-r--r--deps/npm/test/lib/utils/cmd-list.js4
-rw-r--r--deps/npm/test/lib/utils/config/definitions.js11
-rw-r--r--deps/npm/test/lib/utils/config/describe-all.js6
-rw-r--r--deps/npm/test/lib/utils/config/flatten.js38
-rw-r--r--deps/npm/test/lib/utils/config/index.js71
5 files changed, 55 insertions, 75 deletions
diff --git a/deps/npm/test/lib/utils/cmd-list.js b/deps/npm/test/lib/utils/cmd-list.js
deleted file mode 100644
index 8e936946b9..0000000000
--- a/deps/npm/test/lib/utils/cmd-list.js
+++ /dev/null
@@ -1,4 +0,0 @@
-const t = require('tap')
-const cmdList = require('../../../lib/utils/cmd-list.js')
-// just snapshot it so we are made aware if it changes unexpectedly
-t.matchSnapshot(cmdList)
diff --git a/deps/npm/test/lib/utils/config/definitions.js b/deps/npm/test/lib/utils/config/definitions.js
index 200ee9e553..cced42d4d8 100644
--- a/deps/npm/test/lib/utils/config/definitions.js
+++ b/deps/npm/test/lib/utils/config/definitions.js
@@ -13,19 +13,8 @@ const defpath = '../../../../lib/utils/config/definitions.js'
const definitions = require(defpath)
-// Tie the definitions to a snapshot so that if they change we are forced to
-// update snapshots, which rebuilds the docs
-for (const key of Object.keys(definitions)) {
- t.matchSnapshot(definitions[key].describe(), `config description for ${key}`)
-}
-
const isWin = '../../../../lib/utils/is-windows.js'
-// snapshot these just so we note when they change
-t.matchSnapshot(Object.keys(definitions), 'all config keys')
-t.matchSnapshot(Object.keys(definitions).filter(d => d.flatten),
- 'all config keys that are shared to flatOptions')
-
t.equal(definitions['npm-version'].default, pkg.version, 'npm-version default')
t.equal(definitions['node-version'].default, process.version, 'node-version default')
diff --git a/deps/npm/test/lib/utils/config/describe-all.js b/deps/npm/test/lib/utils/config/describe-all.js
deleted file mode 100644
index 814d92ac95..0000000000
--- a/deps/npm/test/lib/utils/config/describe-all.js
+++ /dev/null
@@ -1,6 +0,0 @@
-const t = require('tap')
-const describeAll = require('../../../../lib/utils/config/describe-all.js')
-// this basically ends up being a duplicate of the helpdoc dumped into
-// a snapshot, but it verifies that we get the same help output on every
-// platform where we run CI.
-t.matchSnapshot(describeAll())
diff --git a/deps/npm/test/lib/utils/config/flatten.js b/deps/npm/test/lib/utils/config/flatten.js
deleted file mode 100644
index 7e13563920..0000000000
--- a/deps/npm/test/lib/utils/config/flatten.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const t = require('tap')
-const flatten = require('../../../../lib/utils/config/flatten.js')
-
-require.main.filename = '/path/to/npm'
-delete process.env.NODE
-process.execPath = '/path/to/node'
-
-const obj = {
- 'save-exact': true,
- 'save-prefix': 'ignored',
- 'save-dev': true,
- '@foobar:registry': 'https://foo.bar.com/',
- '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
- userconfig: '/path/to/.npmrc',
-}
-
-const flat = flatten(obj)
-t.strictSame(flat, {
- saveType: 'dev',
- savePrefix: '',
- '@foobar:registry': 'https://foo.bar.com/',
- '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
- npmBin: '/path/to/npm',
- nodeBin: '/path/to/node',
- hashAlgorithm: 'sha1',
-})
-
-// now flatten something else on top of it.
-process.env.NODE = '/usr/local/bin/node.exe'
-flatten({ 'save-dev': false }, flat)
-t.strictSame(flat, {
- savePrefix: '',
- '@foobar:registry': 'https://foo.bar.com/',
- '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
- npmBin: '/path/to/npm',
- nodeBin: '/usr/local/bin/node.exe',
- hashAlgorithm: 'sha1',
-})
diff --git a/deps/npm/test/lib/utils/config/index.js b/deps/npm/test/lib/utils/config/index.js
index 75d72e784f..90931a96d7 100644
--- a/deps/npm/test/lib/utils/config/index.js
+++ b/deps/npm/test/lib/utils/config/index.js
@@ -1,24 +1,63 @@
const t = require('tap')
const config = require('../../../../lib/utils/config/index.js')
-const flatten = require('../../../../lib/utils/config/flatten.js')
const definitions = require('../../../../lib/utils/config/definitions.js')
-const describeAll = require('../../../../lib/utils/config/describe-all.js')
-t.matchSnapshot(config.shorthands, 'shorthands')
+const mockGlobals = require('../../../fixtures/mock-globals.js')
-// just spot check a few of these to show that we got defaults assembled
-t.match(config.defaults, {
- registry: definitions.registry.default,
- 'init-module': definitions['init-module'].default,
+t.test('defaults', t => {
+ // just spot check a few of these to show that we got defaults assembled
+ t.match(config.defaults, {
+ registry: definitions.registry.default,
+ 'init-module': definitions['init-module'].default,
+ })
+
+ // is a getter, so changes are reflected
+ definitions.registry.default = 'https://example.com'
+ t.strictSame(config.defaults.registry, 'https://example.com')
+
+ t.end()
})
-// is a getter, so changes are reflected
-definitions.registry.default = 'https://example.com'
-t.strictSame(config.defaults.registry, 'https://example.com')
+t.test('flatten', t => {
+ // cant use mockGlobals since its not a configurable property
+ require.main.filename = '/path/to/npm'
+ mockGlobals(t, { process: { execPath: '/path/to/node', 'env.NODE': undefined } })
+
+ const obj = {
+ 'save-exact': true,
+ 'save-prefix': 'ignored',
+ 'save-dev': true,
+ '@foobar:registry': 'https://foo.bar.com/',
+ '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
+ userconfig: '/path/to/.npmrc',
+ }
+
+ const flat = config.flatten(obj)
+
+ t.strictSame(flat, {
+ saveType: 'dev',
+ savePrefix: '',
+ '@foobar:registry': 'https://foo.bar.com/',
+ '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
+ npmBin: '/path/to/npm',
+ nodeBin: '/path/to/node',
+ hashAlgorithm: 'sha1',
+ })
+
+ mockGlobals(t, {
+ 'process.env.NODE': '/usr/local/bin/node.exe',
+ })
+
+ // now flatten something else on top of it.
+ config.flatten({ 'save-dev': false }, flat)
+
+ t.strictSame(flat, {
+ savePrefix: '',
+ '@foobar:registry': 'https://foo.bar.com/',
+ '//foo.bar.com:_authToken': 'foobarbazquuxasdf',
+ npmBin: '/path/to/npm',
+ nodeBin: '/usr/local/bin/node.exe',
+ hashAlgorithm: 'sha1',
+ })
-t.strictSame(config, {
- defaults: config.defaults,
- shorthands: config.shorthands,
- flatten,
- definitions,
- describeAll,
+ t.end()
})