From dde03656f154e70045f892b4137f8803edc15564 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Fri, 12 Apr 2024 13:43:13 +0200 Subject: [PATCH] test(node): Add another test case for `parseNpmVcsInfo()` The repository nodes can be textual, see [1]. Add a test to clarify the parsing works for that. [1]: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository Signed-off-by: Frank Viernau --- .../src/test/kotlin/utils/NpmSupportTest.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/package-managers/node/src/test/kotlin/utils/NpmSupportTest.kt b/plugins/package-managers/node/src/test/kotlin/utils/NpmSupportTest.kt index 56c808be743a6..27b23f302c3e6 100644 --- a/plugins/package-managers/node/src/test/kotlin/utils/NpmSupportTest.kt +++ b/plugins/package-managers/node/src/test/kotlin/utils/NpmSupportTest.kt @@ -192,7 +192,7 @@ class NpmSupportTest : WordSpec({ } "parseNpmVcsInfo()" should { - "get VCS information from an object node" { + "get VCS information from an object node containing a repository node which is an object" { val node = """ { "gitHead": "bar", @@ -211,6 +211,21 @@ class NpmSupportTest : WordSpec({ "foo" ) } + + "get VCS information from an object node containing a repository node which is textual" { + val node = """ + { + "gitHead": "bar", + "repository": "git+ssh://example.com/a/b.git" + } + """.readJsonTree() + + parseNpmVcsInfo(node) shouldBe VcsInfo( + VcsType.UNKNOWN, + "git+ssh://example.com/a/b.git", + "bar" + ) + } } "splitNpmNamespaceAndName()" should {