Skip to content

Commit d1185dc

Browse files
committed
add unit test for hoistingLimits fix
1 parent bc03f57 commit d1185dc

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/yarnpkg-nm/tests/hoist.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,18 @@ describe(`hoist`, () => {
666666
};
667667
expect(getTreeHeight(hoist(toTree(tree), {check: true}))).toEqual(4);
668668
});
669+
670+
it(`should hoistingLimits when top level dependency matches a transitive dependency`, () => {
671+
// . -> A -> B -> C
672+
// -> B -> C
673+
// with hoistingLimits: dependencies, C should not be hoisted to the top
674+
const tree = {
675+
'.': {dependencies: [`A`, `B`]},
676+
A: {dependencies: [`B`]},
677+
B: {dependencies: [`C`]},
678+
};
679+
const hoistedTree = hoist(toTree(tree), {check: true, hoistingLimits: new Map([[`.@`, new Set([`A`, `B`])]])});
680+
const C = Array.from(hoistedTree.dependencies).filter(x => x.name === `C`);
681+
expect(C).toEqual([]);
682+
});
669683
});

0 commit comments

Comments
 (0)