Skip to content

Commit

Permalink
✅ Add test for #342.
Browse files Browse the repository at this point in the history
  • Loading branch information
SupremeTechnopriest committed Apr 17, 2023
1 parent 436138d commit 62efb7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/useIdleTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function useIdleTimer ({
}

if (promptBeforeIdle >= timeout) {
throw new Error(`❌ The value for the promptBeforeIdle property be less than the timeout property, ${timeout}.`)
throw new Error(`❌ The value for the promptBeforeIdle property must be less than the timeout property, ${timeout}.`)
}

if (promptBeforeIdle) {
Expand Down
10 changes: 10 additions & 0 deletions tests/useIdleTimer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,16 @@ describe('useIdleTimer', () => {
)
})

it('Should not allow an value greater than or equal to timeout', () => {
props.promptBeforeIdle = 1000
props.timeout = 1000

const { result } = idleTimer()
expect(result.error.message).toBe(
'❌ The value for the promptBeforeIdle property must be less than the timeout property, 1000.'
)
})

it('Should call idle after prompt duration', async () => {
props.timeout = 400
props.promptBeforeIdle = 100
Expand Down

0 comments on commit 62efb7a

Please sign in to comment.