Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions __tests__/project.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { mayhemProjectSlug } from "../src/project";

describe("mayhemProjectSlug", () => {
test("a name that is already a Mayhem slug is unchanged", () => {
expect(mayhemProjectSlug("mcode-action")).toBe("mcode-action");
expect(mayhemProjectSlug("forallsecure/mcode-action")).toBe(
"forallsecure/mcode-action",
);
});

test("it lowercases, as before", () => {
expect(mayhemProjectSlug("ForAllSecure/Mcode-Action")).toBe(
"forallsecure/mcode-action",
);
});

test("an underscore becomes a dash (the case that failed run creation)", () => {
// GITHUB_REPOSITORY for owner/My_Project; Mayhem stores it as my-project.
expect(mayhemProjectSlug("Owner/My_Project")).toBe("owner/my-project");
expect(mayhemProjectSlug("some_lib")).toBe("some-lib");
});

test("a dot becomes a dash", () => {
expect(mayhemProjectSlug("owner/parser.rs")).toBe("owner/parser-rs");
expect(mayhemProjectSlug("some.lib")).toBe("some-lib");
});

test("every other character outside [a-z0-9-] becomes a dash, one for one", () => {
expect(mayhemProjectSlug("a__b.c+d")).toBe("a--b-c-d");
});

test("the owner/project separator is kept", () => {
expect(mayhemProjectSlug("owner/some.lib_legacy")).toBe(
"owner/some-lib-legacy",
);
});
});
Loading
Loading