diff --git a/src/store/review-store.test.ts b/src/store/review-store.test.ts index 291e12ed..09d26e97 100644 --- a/src/store/review-store.test.ts +++ b/src/store/review-store.test.ts @@ -179,4 +179,43 @@ describe("card form store", () => { expect(reviewStore.currentCard).toBeFalsy(); expect(reviewStore.nextCard).toBeFalsy(); }); + + it('hit wrong many times', () => { + const reviewStore = new ReviewStore(); + reviewStore.startDeckReview(deckCardsMock); + expect(reviewStore.isFinished).toBeFalsy(); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + reviewStore.open() + reviewStore.changeState(CardState.Forget); + + expect(reviewStore.result.forgotIds).toHaveLength(3) + expect(reviewStore.result.rememberIds).toHaveLength(0) + + reviewStore.open() + reviewStore.changeState(CardState.Remember); + + reviewStore.open() + reviewStore.changeState(CardState.Remember); + + reviewStore.open() + reviewStore.changeState(CardState.Remember); + + expect(reviewStore.result.forgotIds).toHaveLength(3) + expect(reviewStore.result.rememberIds).toHaveLength(0) + }) }); diff --git a/src/store/review-store.ts b/src/store/review-store.ts index 21f94912..ba0a625b 100644 --- a/src/store/review-store.ts +++ b/src/store/review-store.ts @@ -80,7 +80,9 @@ export class ReviewStore { assert(currentCardIdx !== -1); this.cardsToReview.splice(currentCardIdx, 1); if (currentCard.state === CardState.Forget) { - this.result.forgotIds.push(currentCard.id); + if (!this.result.forgotIds.includes(currentCard.id)) { + this.result.forgotIds.push(currentCard.id); + } currentCard.close(); this.cardsToReview.push(currentCard); }