Skip to content
Closed
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
41 changes: 41 additions & 0 deletions __tests__/project.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 savantenvs/SDL_sound; Mayhem stores it as sdl-sound.
expect(mayhemProjectSlug("SavantEnvs/SDL_sound")).toBe(
Comment thread
d-dot-one marked this conversation as resolved.
"savantenvs/sdl-sound",
);
expect(mayhemProjectSlug("deno_lint")).toBe("deno-lint");
});

test("a dot becomes a dash", () => {
expect(mayhemProjectSlug("savantenvs/gjson.rs")).toBe(
"savantenvs/gjson-rs",
);
expect(mayhemProjectSlug("metapensiero.pj")).toBe("metapensiero-pj");
});

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/dissect.cstruct_legacy")).toBe(
"owner/dissect-cstruct-legacy",
);
});
});
Loading
Loading