From 62efb7a28c81de729446170dd093234e39eba14e Mon Sep 17 00:00:00 2001 From: Randy Lebeau Date: Mon, 17 Apr 2023 15:14:35 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20=20Add=20test=20for=20#342.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/useIdleTimer.tsx | 2 +- tests/useIdleTimer.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/useIdleTimer.tsx b/src/useIdleTimer.tsx index d8ac2f2..d7e68c1 100644 --- a/src/useIdleTimer.tsx +++ b/src/useIdleTimer.tsx @@ -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) { diff --git a/tests/useIdleTimer.test.ts b/tests/useIdleTimer.test.ts index 2487b69..58500f0 100644 --- a/tests/useIdleTimer.test.ts +++ b/tests/useIdleTimer.test.ts @@ -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