Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2021-05-04 19:19:31 +0300
committerGar <gar+gh@danger.computer>2021-05-06 22:46:31 +0300
commitd84b1bd23244c80a49cc9d3edef56b5a102f7c36 (patch)
tree56bbc5f747b0dc52c1c0e4c905ce9a4a74f570fa /test
parent2c9b8713c4c88fbd0c3c48eb0de84dbd7269398f (diff)
feat(config): add workspaces boolean to user-agent
PR-URL: https://github.com/npm/cli/pull/3187 Credit: @nlf Close: #3187 Reviewed-by: @wraithgar
Diffstat (limited to 'test')
-rw-r--r--test/lib/utils/config/definitions.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js
index f73522365..49e415288 100644
--- a/test/lib/utils/config/definitions.js
+++ b/test/lib/utils/config/definitions.js
@@ -729,7 +729,7 @@ t.test('user-agent', t => {
}
const flat = {}
const expectNoCI = `npm/1.2.3 node/9.8.7 ` +
- `${process.platform} ${process.arch}`
+ `${process.platform} ${process.arch} workspaces/false`
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectNoCI)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
@@ -742,6 +742,23 @@ t.test('user-agent', t => {
t.equal(flat.userAgent, expectCI)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+
+ delete obj['ci-name']
+ obj.workspaces = true
+ obj['user-agent'] = definitions['user-agent'].default
+ const expectWorkspaces = expectNoCI.replace('workspaces/false', 'workspaces/true')
+ definitions['user-agent'].flatten('user-agent', obj, flat)
+ t.equal(flat.userAgent, expectWorkspaces)
+ t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
+ t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+
+ delete obj.workspaces
+ obj.workspace = ['foo']
+ obj['user-agent'] = definitions['user-agent'].default
+ definitions['user-agent'].flatten('user-agent', obj, flat)
+ t.equal(flat.userAgent, expectWorkspaces)
+ t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
+ t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
t.end()
})