Add more tests for auto pack naming

This commit is contained in:
Koen Vlaswinkel
2023-06-19 13:51:24 +02:00
parent 3c60708b55
commit 3323fd4e3b
2 changed files with 40 additions and 0 deletions

View File

@@ -25,6 +25,11 @@ export function autoNameExtensionPack(
const parts = packName.split("/");
const sanitizedParts = parts.map((part) => sanitizeExtensionPackName(part));
// If the scope is empty (e.g. if the given name is "-/b"), then we need to still set a scope
if (sanitizedParts[0].length === 0) {
sanitizedParts[0] = "pack";
}
return {
scope: sanitizedParts[0],
// This will ensure there's only 1 slash

View File

@@ -36,6 +36,41 @@ describe("autoNameExtensionPack", () => {
language: "csharp",
expected: "pack/b-csharp",
},
{
name: "a/b/c/d",
language: "csharp",
expected: "a/b-c-d-csharp",
},
{
name: "JAVA/CodeQL",
language: "csharp",
expected: "java/codeql-csharp",
},
{
name: "my new pack",
language: "swift",
expected: "pack/my-new-pack-swift",
},
{
name: "gïthub/vscode-codeql",
language: "javascript",
expected: "gthub/vscode-codeql-javascript",
},
{
name: "a/b-",
language: "csharp",
expected: "a/b-csharp",
},
{
name: "-a-/b",
language: "ruby",
expected: "a/b-ruby",
},
{
name: "a/b--d--e-d-",
language: "csharp",
expected: "a/b-d-e-d-csharp",
},
];
test.each(testCases)(