test(01-03): add failing tests for level definitions

- 13 tests covering levels array, key progressions, finger mappings
- Tests for getLevelByNumber and getKeysUpToLevel helpers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 11:05:56 +02:00
co-authored by Claude Opus 4.6
parent 8ac6a96d98
commit 3462a6704e
+99
View File
@@ -0,0 +1,99 @@
import { describe, expect, it } from "vitest";
import { getKeysUpToLevel, getLevelByNumber, levels } from "./levels";
describe("levels", () => {
it("has exactly 6 entries", () => {
expect(levels).toHaveLength(6);
});
it("Level 1 newKeys = ['f', 'j', ' ']", () => {
expect(levels[0].newKeys).toEqual(["f", "j", " "]);
});
it("Level 2 newKeys = ['d', 'k']", () => {
expect(levels[1].newKeys).toEqual(["d", "k"]);
});
it("Level 3 newKeys = ['s', 'l']", () => {
expect(levels[2].newKeys).toEqual(["s", "l"]);
});
it("Level 4 newKeys = ['a', 'ö']", () => {
expect(levels[3].newKeys).toEqual(["a", "ö"]);
});
it("Level 5 newKeys = ['g', 'h']", () => {
expect(levels[4].newKeys).toEqual(["g", "h"]);
});
it("Level 6 newKeys = ['e', 'i']", () => {
expect(levels[5].newKeys).toEqual(["e", "i"]);
});
it("Level 3 allKeys includes all keys from levels 1-3", () => {
const expected = ["f", "j", " ", "d", "k", "s", "l"];
for (const key of expected) {
expect(levels[2].allKeys).toContain(key);
}
expect(levels[2].allKeys).toHaveLength(expected.length);
});
it("Level 6 allKeys contains 13 keys", () => {
expect(levels[5].allKeys).toHaveLength(13);
const expected = [
"f",
"j",
" ",
"d",
"k",
"s",
"l",
"a",
"ö",
"g",
"h",
"e",
"i",
];
for (const key of expected) {
expect(levels[5].allKeys).toContain(key);
}
});
it("each key in allKeys has a fingerMap entry", () => {
for (const level of levels) {
for (const key of level.allKeys) {
expect(level.fingerMap[key]).toBeDefined();
expect(level.fingerMap[key]).toMatch(/^--finger-/);
}
}
});
});
describe("getLevelByNumber", () => {
it("returns level 1 object", () => {
const level = getLevelByNumber(1);
expect(level).toBeDefined();
expect(level?.level).toBe(1);
expect(level?.newKeys).toEqual(["f", "j", " "]);
});
it("returns undefined for non-existent level", () => {
expect(getLevelByNumber(99)).toBeUndefined();
});
});
describe("getKeysUpToLevel", () => {
it("returns cumulative keys for levels 1-3", () => {
const keys = getKeysUpToLevel(3);
const expected = ["f", "j", " ", "d", "k", "s", "l"];
expect(keys).toHaveLength(expected.length);
for (const key of expected) {
expect(keys).toContain(key);
}
});
it("returns empty array for non-existent level", () => {
expect(getKeysUpToLevel(99)).toEqual([]);
});
});