Skip to content

Commit

Permalink
✅ a Yarn monorepo test was added
Browse files Browse the repository at this point in the history
  • Loading branch information
noyshabtay committed Nov 23, 2023
1 parent 39139ed commit 139c601
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/test/java/com/jfrog/ide/idea/scan/YarnScannerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,24 @@ public void testWalkDepTreeMonorepo() throws IOException {
assertEquals(vulnerableDependencies.length, packageJsonNode.getChildren().size());

// Check the impact graph correctness.
String packageId = null;
boolean isIndirect = false;
int actualImpactPathsCount = 0;
for (TreeNode treeNode : packageJsonNode.getChildren()) {
DependencyNode dependencyNode = (DependencyNode) treeNode;
if (dependencyNode.getComponentId().equals("axios:1.5.1")) {
packageId = "axios:1.5.1";
isIndirect = false;
actualImpactPathsCount = 3;
} else if (dependencyNode.getComponentId().equals("lodash:4.16.2")) {
packageId = "lodash:4.16.2";
isIndirect = true;
actualImpactPathsCount = 1;
} else if (dependencyNode.getComponentId().equals("cli-table:0.3.1")) {
packageId = "cli-table:0.3.1";
isIndirect = false;
actualImpactPathsCount = 1;
} else {
fail("Unexpected dependency " + dependencyNode.getComponentId());
switch (dependencyNode.getComponentId()) {
case "axios:1.5.1" -> {
isIndirect = false;
actualImpactPathsCount = 3;
}
case "lodash:4.16.2" -> {
isIndirect = true;
actualImpactPathsCount = 1;
}
case "cli-table:0.3.1" -> {
isIndirect = false;
actualImpactPathsCount = 1;
}
default -> fail("Unexpected dependency " + dependencyNode.getComponentId());
}
assertEquals(isIndirect, dependencyNode.isIndirect());
assertEquals(actualImpactPathsCount, dependencyNode.getImpactTree().getImpactPathsCount());
Expand Down

0 comments on commit 139c601

Please sign in to comment.