Files
miti99bot/tests/modules/loldle-quote/state.test.js
T
tiennm99 bd5626534b feat(loldle): add emoji and quote champion-guessing modules
Ship two new loldle-family modules mirroring loldle.net's non-classic
modes. Text-only MVP (ability/splash phases stay deferred).

- loldle-emoji: 5 guesses, emoji-sequence clue. Pool derived algorithmically
  from classic's champions.json metadata (species/region/resource mapping
  table) since loldle.net's bundle has no static emoji pool.
- loldle-quote: 6 guesses, lore-blurb clue. Pool seeded from Data Dragon
  champion title + first lore sentence; champion name redacted to ___.
- scripts/fetch-ddragon-data.js: single generator for both JSONs.
- src/util/normalize-name.js: shared lookup helper; loldle/lookup.js
  refactored to import it.

35 new tests (484 total passing). Lint clean.
2026-04-24 23:30:11 +07:00

40 lines
1.2 KiB
JavaScript

import { beforeEach, describe, expect, it } from "vitest";
import { createStore } from "../../../src/db/create-store.js";
import {
clearGame,
loadGame,
loadStats,
recordResult,
saveGame,
} from "../../../src/modules/loldle-quote/state.js";
import { makeFakeKv } from "../../fakes/fake-kv-namespace.js";
describe("loldle-quote state", () => {
let db;
beforeEach(() => {
db = createStore("loldle-quote", { KV: makeFakeKv() });
});
it("round-trips a game", async () => {
const state = { target: "Garen", guesses: [], startedAt: null };
await saveGame(db, 99, state);
expect(await loadGame(db, 99)).toEqual(state);
});
it("clearGame deletes the record", async () => {
await saveGame(db, 99, { target: "Garen", guesses: [], startedAt: null });
await clearGame(db, 99);
expect(await loadGame(db, 99)).toBeNull();
});
it("recordResult tracks streaks and bestStreak", async () => {
await recordResult(db, 99, true);
await recordResult(db, 99, true);
await recordResult(db, 99, true);
await recordResult(db, 99, false);
const s = await loadStats(db, 99);
expect(s).toMatchObject({ played: 4, wins: 3, streak: 0, bestStreak: 3 });
});
});