diff --git a/src/companion/companion.test.ts b/src/companion/companion.test.ts index 48af0ef..dce25e7 100644 --- a/src/companion/companion.test.ts +++ b/src/companion/companion.test.ts @@ -169,7 +169,7 @@ describe("getLetterIntro", () => { const result = await getLetterIntro( "fee", - "z", + "@", "linker kleiner Finger", db, ); diff --git a/src/game/levels.test.ts b/src/game/levels.test.ts index 4df1873..472b988 100644 --- a/src/game/levels.test.ts +++ b/src/game/levels.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { getKeysUpToLevel, getLevelByNumber, levels } from "./levels"; describe("levels", () => { - it("has exactly 6 entries", () => { - expect(levels).toHaveLength(6); + it("has exactly 16 entries", () => { + expect(levels).toHaveLength(16); }); it("Level 1 newKeys = ['f', 'j', ' ']", () => { @@ -30,6 +30,46 @@ describe("levels", () => { expect(levels[5]!.newKeys).toEqual(["e", "i"]); }); + it("Level 7 newKeys = ['r', 'u']", () => { + expect(levels[6]!.newKeys).toEqual(["r", "u"]); + }); + + it("Level 8 newKeys = ['t', 'z']", () => { + expect(levels[7]!.newKeys).toEqual(["t", "z"]); + }); + + it("Level 9 newKeys = ['w', 'o']", () => { + expect(levels[8]!.newKeys).toEqual(["w", "o"]); + }); + + it("Level 10 newKeys = ['q', 'p']", () => { + expect(levels[9]!.newKeys).toEqual(["q", "p"]); + }); + + it("Level 11 newKeys = ['n', 'b']", () => { + expect(levels[10]!.newKeys).toEqual(["n", "b"]); + }); + + it("Level 12 newKeys = ['v', 'm']", () => { + expect(levels[11]!.newKeys).toEqual(["v", "m"]); + }); + + it("Level 13 newKeys = ['c', 'x']", () => { + expect(levels[12]!.newKeys).toEqual(["c", "x"]); + }); + + it("Level 14 newKeys = ['ä', 'ü']", () => { + expect(levels[13]!.newKeys).toEqual(["ä", "ü"]); + }); + + it("Level 15 newKeys = ['y', ',']", () => { + expect(levels[14]!.newKeys).toEqual(["y", ","]); + }); + + it("Level 16 newKeys = ['.']", () => { + expect(levels[15]!.newKeys).toEqual(["."]); + }); + it("Level 3 allKeys includes all keys from levels 1-3", () => { const expected = ["f", "j", " ", "d", "k", "s", "l"]; for (const key of expected) { @@ -60,6 +100,14 @@ describe("levels", () => { } }); + it("Level 16 allKeys contains all QWERTZ keys", () => { + const expected = "fjdkslagöheiruztwopqnbvmcxäüy,.".split("").concat([" "]); + expect(levels[15]!.allKeys).toHaveLength(expected.length); + for (const key of expected) { + expect(levels[15]!.allKeys).toContain(key); + } + }); + it("each key in allKeys has a fingerMap entry", () => { for (const level of levels) { for (const key of level.allKeys) { diff --git a/src/game/words.test.ts b/src/game/words.test.ts index e4327fc..f3ae27f 100644 --- a/src/game/words.test.ts +++ b/src/game/words.test.ts @@ -1,23 +1,23 @@ -import { describe, it, expect } from "vitest"; -import { wordsByLevel, getWordsForLevel } from "./words"; +import { describe, expect, it } from "vitest"; import { getKeysUpToLevel } from "./levels"; +import { getWordsForLevel, validateWordList, wordsByLevel } from "./words"; describe("wordsByLevel", () => { - it("has entries for levels 1-6", () => { - for (let level = 1; level <= 6; level++) { + it("has entries for levels 1-16", () => { + for (let level = 1; level <= 16; level++) { expect(wordsByLevel[level]).toBeDefined(); expect(Array.isArray(wordsByLevel[level])).toBe(true); } }); it("each level has at least 8 words", () => { - for (let level = 1; level <= 6; level++) { + for (let level = 1; level <= 16; level++) { expect(wordsByLevel[level]!.length).toBeGreaterThanOrEqual(8); } }); it("every word in level N uses only characters from that level's allKeys (no spaces)", () => { - for (let level = 1; level <= 6; level++) { + for (let level = 1; level <= 16; level++) { const allowedKeys = getKeysUpToLevel(level).filter((k) => k !== " "); const words = wordsByLevel[level]!; for (const word of words) { @@ -32,7 +32,7 @@ describe("wordsByLevel", () => { }); it("no word exceeds 5 characters", () => { - for (let level = 1; level <= 6; level++) { + for (let level = 1; level <= 16; level++) { const words = wordsByLevel[level]!; for (const word of words) { expect( @@ -42,6 +42,10 @@ describe("wordsByLevel", () => { } } }); + + it("validateWordList confirms all words use only allowed keys", () => { + expect(validateWordList()).toBe(true); + }); }); describe("getWordsForLevel", () => {