sendou.ink/app/modules/brackets-manager/test/get.test.ts
Kalle 700a309e7f
Migrate Node -> Bun (#1827)
* Initial

* Faster user page

* Remove redundant function

* Favorite badge sorting

* Upgrade deps

* Simplify entry.server

* Bun tests initial

* Update package.json npm -> bun

* Update README

* Type safe translations again

* Don't load streams info for finalized tournaments

* Translations as an object

* More unit test work

* Convert match.server.test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* Test & all done

* Working cf

* Bun GA try

* No cache

* spacing

* spacing 2

* Add SQL logging

* Remove NR

* Hmm

* Hmm 2

* Interesting

* SKALOP_SYSTEM_MESSAGE_URL

* .

* .

* ?

* .

* ?

* Server.ts adjust

* Downgrade Tldraw

* E2E test fix

* Fix lint
2024-08-11 16:09:41 +03:00

90 lines
2.0 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";
const storage = new InMemoryDatabase();
const manager = new BracketsManager(storage);
describe("Get seeding", () => {
test("should get the seeding of a round-robin stage", () => {
storage.reset();
manager.create({
name: "Example",
tournamentId: 0,
type: "round_robin",
settings: {
groupCount: 8,
size: 32,
seedOrdering: ["groups.seed_optimized"],
},
});
const seeding = manager.get.seeding(0);
expect(seeding.length).toBe(32);
expect(seeding[0]!.position).toBe(1);
expect(seeding[1]!.position).toBe(2);
});
test("should get the seeding of a round-robin stage with BYEs", () => {
storage.reset();
manager.create({
name: "Example",
tournamentId: 0,
type: "round_robin",
settings: {
groupCount: 2,
size: 8,
},
seeding: [1, null, null, null, null, null, null, null],
});
const seeding = manager.get.seeding(0);
expect(seeding.length).toBe(8);
});
test("should get the seeding of a single elimination stage", () => {
storage.reset();
manager.create({
name: "Example",
tournamentId: 0,
type: "single_elimination",
settings: { size: 16 },
});
const seeding = manager.get.seeding(0);
expect(seeding.length).toBe(16);
expect(seeding[0]!.position).toBe(1);
expect(seeding[1]!.position).toBe(2);
});
test("should get the seeding with BYEs", () => {
storage.reset();
manager.create({
name: "Example",
tournamentId: 0,
type: "single_elimination",
seeding: [1, null, 2, 3, 4, null, null, 5],
settings: {
seedOrdering: ["inner_outer"],
},
});
const seeding = manager.get.seeding(0);
expect(seeding.length).toBe(8);
expect(seeding).toEqual([
{ id: 1, position: 1 },
null,
{ id: 2, position: 3 },
{ id: 3, position: 4 },
{ id: 4, position: 5 },
null,
null,
{ id: 5, position: 8 },
]);
});
});