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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user