sendou.ink/app/features/team/actions/t.server.test.ts
Kalle aea1e9ce35
Toasts (#2132)
* Fix unexpected server error when trying to access non-existing tournament team page

* Fix Catcher textarea usage

* Fix unexpected server error on LFG page

* Validator for duplicate tournament team name

* initial

* Fix tests

* Success toast

* Done?

* Fix leftover
2025-03-07 22:20:29 +02:00

36 lines
991 B
TypeScript
Raw 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 { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
assertResponseErrored,
dbInsertUsers,
dbReset,
wrappedAction,
} from "~/utils/Test";
import { action as teamIndexPageAction } from "../actions/t.server";
import type { createTeamSchema } from "../team-schemas.server";
const action = wrappedAction<typeof createTeamSchema>({
action: teamIndexPageAction,
});
describe("team creation", () => {
beforeEach(async () => {
await dbInsertUsers();
});
afterEach(() => {
dbReset();
});
it("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.errors[0]).toBe("forms.errors.duplicateName");
});
it("prevents creating a team whose name is only special characters", async () => {
const response = await action({ name: "𝓢𝓲𝓵" }, { user: "regular" });
assertResponseErrored(response);
});
});