fix(db): atomic saveMnemonic, const normalizedLetter, updateProfileSeen guard, ?? 0 for avgScore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 00:46:05 +00:00
parent 2d96d37866
commit d8de79ce7d
2 changed files with 27 additions and 15 deletions
+11
View File
@@ -159,6 +159,17 @@ describe('mnemonics', () => {
assert.equal(m.A, 'go WALKING')
assert.equal(m.E, 'go')
})
test('saveMnemonic awards 50 pts on first save, not on update', () => {
const p1 = db.getOrCreateProgress(profileId)
db.saveMnemonic(profileId, 'T', 'dash') // first save → +50 pts
const p2 = db.getOrCreateProgress(profileId)
assert.equal(p2.score, p1.score + 50)
db.saveMnemonic(profileId, 'T', 'updated dash') // update → no extra pts
const p3 = db.getOrCreateProgress(profileId)
assert.equal(p3.score, p2.score)
})
})
describe('letter stats', () => {