From 760ed1f8a2988dbfeef34507719a946d2d3e07a2 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Tue, 27 Aug 2024 00:05:49 +0800 Subject: [PATCH] Add unit test of memory state (#119) * Add unit test of memory state * Update __tests__/FSRSV5.test.ts Co-authored-by: ishiko --------- Co-authored-by: ishiko --- __tests__/FSRSV5.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/__tests__/FSRSV5.test.ts b/__tests__/FSRSV5.test.ts index e5d6c71..0e1bd06 100644 --- a/__tests__/FSRSV5.test.ts +++ b/__tests__/FSRSV5.test.ts @@ -61,6 +61,30 @@ describe('FSRS V5 ', () => { ]) }) + it('memory state', () => { + let card = createEmptyCard() + let now = new Date(2022, 11, 29, 12, 30, 0, 0) + let scheduling_cards = f.repeat(card, now) + const ratings: Grade[] = [ + Rating.Again, + Rating.Good, + Rating.Good, + Rating.Good, + Rating.Good, + Rating.Good, + ] + const intervals: number[] = [0, 0, 1, 3, 8, 21] + for (const [index, rating] of ratings.entries()) { + card = scheduling_cards[rating].card + now = new Date(now.getTime() + intervals[index] * 24 * 60 * 60 * 1000) + scheduling_cards = f.repeat(card, now) + } + + const { stability, difficulty } = scheduling_cards[Rating.Good].card + expect(stability).toBeCloseTo(71.4554, 4) + expect(difficulty).toBeCloseTo(5.0976, 4) + }) + it('first repeat', () => { const card = createEmptyCard() const now = new Date(2022, 11, 29, 12, 30, 0, 0)