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:
@@ -169,7 +169,7 @@ describe("getLetterIntro", () => {
|
||||
|
||||
const result = await getLetterIntro(
|
||||
"fee",
|
||||
"z",
|
||||
"@",
|
||||
"linker kleiner Finger",
|
||||
db,
|
||||
);
|
||||
|
||||
+50
-2
@@ -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) {
|
||||
|
||||
+11
-7
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user