test(morse): add missing coverage for DEFAULT_WPM, DEFAULT_TIMING, and derived timing fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 00:17:33 +00:00
parent f7ad8aa3cc
commit 1bfd5a22fe
2 changed files with 22 additions and 1 deletions
+21
View File
@@ -4,6 +4,8 @@ import {
NOVICE_LETTERS, NOVICE_LETTERS,
OPERATOR_WORDS, OPERATOR_WORDS,
wpmToTiming, wpmToTiming,
DEFAULT_WPM,
DEFAULT_TIMING,
validatePhrase, validatePhrase,
pickChallenge, pickChallenge,
} from './morse' } from './morse'
@@ -37,6 +39,13 @@ describe('OPERATOR_WORDS', () => {
}) })
}) })
describe('DEFAULT_WPM and DEFAULT_TIMING', () => {
it('DEFAULT_WPM is 10', () => expect(DEFAULT_WPM).toBe(10))
it('DEFAULT_TIMING equals wpmToTiming(10)', () => {
expect(DEFAULT_TIMING).toEqual(wpmToTiming(10))
})
})
describe('wpmToTiming', () => { describe('wpmToTiming', () => {
it('10 WPM gives dot=120ms', () => { it('10 WPM gives dot=120ms', () => {
expect(wpmToTiming(10).dot).toBe(120) expect(wpmToTiming(10).dot).toBe(120)
@@ -48,6 +57,18 @@ describe('wpmToTiming', () => {
it('20 WPM gives dot=60ms', () => { it('20 WPM gives dot=60ms', () => {
expect(wpmToTiming(20).dot).toBe(60) expect(wpmToTiming(20).dot).toBe(60)
}) })
it('elementGap equals dot', () => {
const t = wpmToTiming(10)
expect(t.elementGap).toBe(t.dot)
})
it('charGap is 3x dot', () => {
const t = wpmToTiming(10)
expect(t.charGap).toBe(t.dot * 3)
})
it('wordGap is 7x dot', () => {
const t = wpmToTiming(10)
expect(t.wordGap).toBe(t.dot * 7)
})
}) })
describe('validatePhrase', () => { describe('validatePhrase', () => {
+1 -1
View File
@@ -85,7 +85,7 @@ export function pickChallenge(
const weights = available.map(item => { const weights = available.map(item => {
const s = stats[item] const s = stats[item]
if (!s || s.attempts === 0) return 2 if (!s || s.attempts === 0) return 2 // unseen: prioritise over even 0%-accuracy items
const accuracy = s.correct / s.attempts const accuracy = s.correct / s.attempts
return Math.max(0.1, 1 - accuracy) + 0.1 return Math.max(0.1, 1 - accuracy) + 0.1
}) })