Files
sendou.ink/apps/web-react/app/features/team/actions/t.new.server.test.ts

30 lines
1.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { beforeEach, describe, expect, test } from "vitest";
import * as UserFactory from "~/db/seed/factories/UserFactory";
import { wrappedAction } from "~/utils/Test";
import { action as teamIndexPageAction } from "../actions/t.new.server";
import type { createTeamSchema } from "../team-schemas";
const action = wrappedAction<typeof createTeamSchema>({
action: teamIndexPageAction,
isJsonSubmission: true,
});
describe("team creation", () => {
beforeEach(async () => {
await UserFactory.createRegular();
});
test("prevents creating a team with a duplicate name", async () => {
await action({ name: "Team 1" }, { user: "regular" });
const res = await action({ name: "Team 1" }, { user: "regular" });
expect(res.fieldErrors.name).toBe("forms:errors.duplicateName");
});
test("prevents creating a team whose name is only special characters", async () => {
const res = await action({ name: "𝓢𝓲𝓵" }, { user: "regular" });
expect(res.fieldErrors.name).toBe("forms:errors.noOnlySpecialCharacters");
});
});