mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-20 02:08:33 -05:00
* 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
36 lines
991 B
TypeScript
36 lines
991 B
TypeScript
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);
|
||
});
|
||
});
|