test(260329-uos): update tests for 16 levels

- levels.test.ts: change length assertion to 16, add newKeys tests for levels 7-16
- levels.test.ts: add Level 16 allKeys completeness test (all QWERTZ keys)
- words.test.ts: extend all loops from 6 to 16 levels, add validateWordList test
- companion.test.ts: fix unknown-letter test to use '@' (z now has a fallback entry)
This commit is contained in:
2026-03-29 22:15:24 +02:00
parent 1d4c709fb6
commit 3a71799823
3 changed files with 62 additions and 10 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ describe("getLetterIntro", () => {
const result = await getLetterIntro( const result = await getLetterIntro(
"fee", "fee",
"z", "@",
"linker kleiner Finger", "linker kleiner Finger",
db, db,
); );
+50 -2
View File
@@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest";
import { getKeysUpToLevel, getLevelByNumber, levels } from "./levels"; import { getKeysUpToLevel, getLevelByNumber, levels } from "./levels";
describe("levels", () => { describe("levels", () => {
it("has exactly 6 entries", () => { it("has exactly 16 entries", () => {
expect(levels).toHaveLength(6); expect(levels).toHaveLength(16);
}); });
it("Level 1 newKeys = ['f', 'j', ' ']", () => { it("Level 1 newKeys = ['f', 'j', ' ']", () => {
@@ -30,6 +30,46 @@ describe("levels", () => {
expect(levels[5]!.newKeys).toEqual(["e", "i"]); 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", () => { it("Level 3 allKeys includes all keys from levels 1-3", () => {
const expected = ["f", "j", " ", "d", "k", "s", "l"]; const expected = ["f", "j", " ", "d", "k", "s", "l"];
for (const key of expected) { 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", () => { it("each key in allKeys has a fingerMap entry", () => {
for (const level of levels) { for (const level of levels) {
for (const key of level.allKeys) { for (const key of level.allKeys) {
+11 -7
View File
@@ -1,23 +1,23 @@
import { describe, it, expect } from "vitest"; import { describe, expect, it } from "vitest";
import { wordsByLevel, getWordsForLevel } from "./words";
import { getKeysUpToLevel } from "./levels"; import { getKeysUpToLevel } from "./levels";
import { getWordsForLevel, validateWordList, wordsByLevel } from "./words";
describe("wordsByLevel", () => { describe("wordsByLevel", () => {
it("has entries for levels 1-6", () => { it("has entries for levels 1-16", () => {
for (let level = 1; level <= 6; level++) { for (let level = 1; level <= 16; level++) {
expect(wordsByLevel[level]).toBeDefined(); expect(wordsByLevel[level]).toBeDefined();
expect(Array.isArray(wordsByLevel[level])).toBe(true); expect(Array.isArray(wordsByLevel[level])).toBe(true);
} }
}); });
it("each level has at least 8 words", () => { 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); expect(wordsByLevel[level]!.length).toBeGreaterThanOrEqual(8);
} }
}); });
it("every word in level N uses only characters from that level's allKeys (no spaces)", () => { 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 allowedKeys = getKeysUpToLevel(level).filter((k) => k !== " ");
const words = wordsByLevel[level]!; const words = wordsByLevel[level]!;
for (const word of words) { for (const word of words) {
@@ -32,7 +32,7 @@ describe("wordsByLevel", () => {
}); });
it("no word exceeds 5 characters", () => { it("no word exceeds 5 characters", () => {
for (let level = 1; level <= 6; level++) { for (let level = 1; level <= 16; level++) {
const words = wordsByLevel[level]!; const words = wordsByLevel[level]!;
for (const word of words) { for (const word of words) {
expect( expect(
@@ -42,6 +42,10 @@ describe("wordsByLevel", () => {
} }
} }
}); });
it("validateWordList confirms all words use only allowed keys", () => {
expect(validateWordList()).toBe(true);
});
}); });
describe("getWordsForLevel", () => { describe("getWordsForLevel", () => {