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
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-01-20 23:37:43 +0300
committerGitHub <noreply@github.com>2022-01-20 23:37:43 +0300
commitc99c2151a868672c017f64ff0ecb12149a2fb095 (patch)
treef69903b0ea2523637e106d8191880a17cfd260f4 /workspaces/arborist/test
parentcfd59b8c81078f842328b13a23a234150842cd58 (diff)
fix(arborist): prioritize valid workspace nodes (#4230)
closes #3637
Diffstat (limited to 'workspaces/arborist/test')
-rw-r--r--workspaces/arborist/test/arborist/build-ideal-tree.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/workspaces/arborist/test/arborist/build-ideal-tree.js b/workspaces/arborist/test/arborist/build-ideal-tree.js
index 8ec8dab91..2c058a6a3 100644
--- a/workspaces/arborist/test/arborist/build-ideal-tree.js
+++ b/workspaces/arborist/test/arborist/build-ideal-tree.js
@@ -833,6 +833,50 @@ t.test('workspaces', t => {
)
})
+ t.test('should allow adding a workspace as a dep to a workspace', async t => {
+ // turn off networking, this should never make a registry request
+ nock.disableNetConnect()
+ t.teardown(() => nock.enableNetConnect())
+
+ const path = t.testdir({
+ 'package.json': JSON.stringify({
+ name: 'root',
+ workspaces: ['workspace-a', 'workspace-b'],
+ }),
+ 'workspace-a': {
+ 'package.json': JSON.stringify({
+ name: 'workspace-a',
+ version: '1.0.0',
+ }),
+ },
+ 'workspace-b': {
+ 'package.json': JSON.stringify({
+ name: 'workspace-b',
+ version: '1.0.0',
+ }),
+ },
+ })
+
+ const arb = new Arborist({
+ ...OPT,
+ path,
+ workspaces: ['workspace-a'],
+ })
+
+ const tree = arb.buildIdealTree({
+ path,
+ add: [
+ 'workspace-b',
+ ],
+ })
+
+ // just assert that the buildIdealTree call resolves, if there's a
+ // problem here it will reject because of nock disabling requests
+ await t.resolves(tree)
+
+ t.matchSnapshot(printTree(await tree))
+ })
+
t.end()
})