Files
movie-select/tests/shared/round-state.test.ts
Felix Förtsch 265cd329f6 refactor to react/vite/hono/drizzle/postgresql stack
replace vanilla TS + Bun.serve() + MariaDB with:
- frontend: React 19, Vite 6, TanStack Router/Query, Tailwind v4
- backend: Hono + @hono/node-server, Drizzle ORM, PostgreSQL, Zod
- shared: algorithm, round-state, types in src/shared/
- tooling: Biome (lint/format), Vitest (tests)
- deploy: static files at /movie-select/, API at /movie-select/api

URL scheme changes from /movies/ to /movie-select/,
API from action-based to RESTful endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 15:03:35 +01:00

26 lines
800 B
TypeScript

import { expect, test } from "vitest";
import {
allUsersDone,
collectCompleteRatings,
hasCompleteRatings,
} from "../../src/shared/round-state.ts";
test("allUsersDone returns true when all done", () => {
expect(allUsersDone(["A", "B"], ["A", "B"])).toBe(true);
expect(allUsersDone(["A", "B"], ["A"])).toBe(false);
expect(allUsersDone([], [])).toBe(false);
});
test("hasCompleteRatings detects missing ratings", () => {
expect(hasCompleteRatings(["M1", "M2"], { M1: 2, M2: 5 })).toBe(true);
expect(hasCompleteRatings(["M1", "M2"], { M1: 2 })).toBe(false);
});
test("collectCompleteRatings filters incomplete voters", () => {
const result = collectCompleteRatings(["A", "B"], ["M1", "M2"], {
A: { M1: 1, M2: 2 },
B: { M1: 3 },
});
expect(result).toEqual({ A: { M1: 1, M2: 2 } });
});