test(npm-shrinkwrap): Added test support for peerDependencies.
@@ -9,8 +9,8 @@ import org.junit.jupiter.api.Assertions;
import com.synopsys.integration.bdio.model.Forge;
import com.synopsys.integration.detectable.Detectable;
import com.synopsys.integration.detectable.DetectableEnvironment;
-import com.synopsys.integration.detectable.extraction.Extraction;
import com.synopsys.integration.detectable.detectables.npm.lockfile.NpmLockfileOptions;
+import com.synopsys.integration.detectable.extraction.Extraction;
import com.synopsys.integration.detectable.functional.DetectableFunctionalTest;
import com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert;
@@ -53,6 +53,10 @@ public class NpmShrinkwrapDetectableTest extends DetectableFunctionalTest {
" \"negotiator\": {",
" \"version\": \"https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz\",",
" \"integrity\": \"sha1-wY29fHOl2/b0SgJNwNFloeexw5I=\"",
+ " },",
+ " \"peer-example\": {",
+ " \"version\": \"1.0.0\",",
+ " \"integrity\": \"sha1-wY36fHOl2/b0SgJNwNFloeexw57=\"",
" }",
" }",
"}"
@@ -61,22 +65,23 @@ public class NpmShrinkwrapDetectableTest extends DetectableFunctionalTest {
@NotNull
@Override
- public Detectable create(@NotNull final DetectableEnvironment detectableEnvironment) {
- return detectableFactory.createNpmShrinkwrapDetectable(detectableEnvironment, new NpmLockfileOptions(true));
+ public Detectable create(@NotNull DetectableEnvironment detectableEnvironment) {
+ return detectableFactory.createNpmShrinkwrapDetectable(detectableEnvironment, new NpmLockfileOptions(true, true));
}
@Override
- public void assertExtraction(@NotNull final Extraction extraction) {
+ public void assertExtraction(@NotNull Extraction extraction) {
Assertions.assertEquals(1, extraction.getCodeLocations().size(), "A code location should have been generated.");
- final NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, extraction.getCodeLocations().get(0).getDependencyGraph());
+ NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, extraction.getCodeLocations().get(0).getDependencyGraph());
- graphAssert.hasRootSize(5);
+ graphAssert.hasRootSize(6);
graphAssert.hasRootDependency("abbrev", "1.0.9");
graphAssert.hasRootDependency("accepts", "1.3.3");
graphAssert.hasRootDependency("mime-types", "https://registry.npmjs.org/mime-types/-/mime-types-2.1.13.tgz");
graphAssert.hasRootDependency("mime-db", "https://registry.npmjs.org/mime-db/-/mime-db-1.25.0.tgz");
graphAssert.hasRootDependency("negotiator", "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz");
+ graphAssert.hasRootDependency("peer-example", "1.0.0");
graphAssert.hasParentChildRelationship("accepts", "1.3.3", "mime-types", "https://registry.npmjs.org/mime-types/-/mime-types-2.1.13.tgz");
graphAssert.hasParentChildRelationship("mime-types", "https://registry.npmjs.org/mime-types/-/mime-types-2.1.13.tgz", "mime-db", "https://registry.npmjs.org/mime-db/-/mime-db-1.25.0.tgz");
graphAssert.hasParentChildRelationship("accepts", "1.3.3", "negotiator", "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz");
