Skip to content

Commit

Permalink
pass the test
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Sep 12, 2024
1 parent 0e57fa7 commit 8d6d9d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __tests__/FSRSV5.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ describe('FSRS V5 ', () => {

describe('get retrievability', () => {
const fsrs = new FSRS({})
test('return 0% for new cards', () => {
test('return 0.00% for new cards', () => {
const card = createEmptyCard()
const now = new Date()
const expected = "0%"
const expected = "0.00%"
expect(fsrs.get_retrievability(card, now)).toBe(expected)
})

Expand Down
2 changes: 1 addition & 1 deletion src/fsrs/fsrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class FSRS extends FSRSAlgorithm {
): (T extends true ? string : number) {
const processedCard = TypeConvert.card(card)
now = now ? TypeConvert.time(now) : new Date()
const t = Math.max(now.diff(processedCard.last_review as Date, 'days'), 0)
const t = processedCard.state !== State.New ? Math.max(now.diff(processedCard.last_review as Date, 'days'), 0) : 0
const r = processedCard.state !== State.New ? this.forgetting_curve(t, +processedCard.stability.toFixed(2)) : 0
return (format ? `${(r * 100).toFixed(2)}%` : r) as T extends true
? string
Expand Down

0 comments on commit 8d6d9d1

Please sign in to comment.