-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle paying field is undefined (#1605)
This fixes a regression where limits were enforced wrongly.
- Loading branch information
Showing
2 changed files
with
36 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import { checkFlashcardsLimits } from './checkFlashcardsLimits'; | ||
|
||
describe('checkLimits', () => { | ||
|
||
test('throws an error if more than 100 cards are added for anon', () => { | ||
expect(() => checkFlashcardsLimits({ | ||
decks: [], | ||
paying: false, | ||
cards: 101 | ||
})).toThrow(); | ||
expect(() => | ||
checkFlashcardsLimits({ | ||
decks: [], | ||
paying: false, | ||
cards: 101, | ||
}) | ||
).toThrow(); | ||
}); | ||
|
||
test('does not throw an error if 100 cards are added by patreon or subscriber', () => { | ||
expect(() => checkFlashcardsLimits({ | ||
decks: [], | ||
paying: true, | ||
cards: 200 | ||
})).not.toThrow(); | ||
expect(() => checkFlashcardsLimits({ | ||
decks: [], | ||
cards: 500, | ||
paying: true, | ||
})).not.toThrow(); | ||
}) | ||
expect(() => | ||
checkFlashcardsLimits({ | ||
decks: [], | ||
paying: true, | ||
cards: 200, | ||
}) | ||
).not.toThrow(); | ||
expect(() => | ||
checkFlashcardsLimits({ | ||
decks: [], | ||
cards: 500, | ||
paying: true, | ||
}) | ||
).not.toThrow(); | ||
}); | ||
|
||
test('does not throw an error if 51 cards are added by anon', () => { | ||
expect(() => | ||
checkFlashcardsLimits({ | ||
decks: [], | ||
paying: undefined, | ||
cards: 51, | ||
}) | ||
).not.toThrow(); | ||
}); | ||
}); |