Skip to content

Commit e664c61

Browse files
πŸ”€ Merge from master.
2 parents cc863cf + 096b8c1 commit e664c61

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

β€Ždocs/pages/docs/about/changelog.mdxβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Changelog
33
description: IdleTimer Changelog
44
---
5+
56
### 5.6.2
67

78
#### ✨ Enhancements

β€Žsrc/useIdleTimer.tsxβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export function useIdleTimer ({
9696
throw new Error(`❌ The value for the promptBeforeIdle property must fit in a 32 bit signed integer, ${MAX_TIMEOUT}.`)
9797
}
9898

99+
if (promptBeforeIdle >= timeout) {
100+
throw new Error(`❌ The value for the promptBeforeIdle property must be less than the timeout property, ${timeout}.`)
101+
}
102+
99103
if (promptBeforeIdle) {
100104
timeoutRef.current = timeout - promptBeforeIdle
101105
promptTimeoutRef.current = promptBeforeIdle

β€Žtests/useIdleTimer.test.tsβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ describe('useIdleTimer', () => {
449449
)
450450
})
451451

452+
it('Should not allow an value greater than or equal to timeout', () => {
453+
props.promptBeforeIdle = 1000
454+
props.timeout = 1000
455+
456+
const { result } = idleTimer()
457+
expect(result.error.message).toBe(
458+
'❌ The value for the promptBeforeIdle property must be less than the timeout property, 1000.'
459+
)
460+
})
461+
452462
it('Should call idle after prompt duration', async () => {
453463
props.timeout = 400
454464
props.promptBeforeIdle = 100

0 commit comments

Comments
Β (0)