Skip to content

Commit

Permalink
Add unit test of memory state (#119)
Browse files Browse the repository at this point in the history
* Add unit test of memory state

* Update __tests__/FSRSV5.test.ts

Co-authored-by: ishiko <ishiko732@gmail.com>

---------

Co-authored-by: ishiko <ishiko732@gmail.com>
  • Loading branch information
L-M-Sherlock and ishiko732 authored Aug 26, 2024
1 parent 16c630c commit 760ed1f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions __tests__/FSRSV5.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 760ed1f

Please sign in to comment.