From db2a927e2eeede9d92ea579c8cc09ea41eb64b1c Mon Sep 17 00:00:00 2001 From: Lyza Danger Gardner Date: Fri, 10 Mar 2023 08:54:57 -0500 Subject: [PATCH] Fix test coverage miss for event hooks --- src/hooks/test/use-click-away-test.js | 3 ++- src/hooks/test/use-focus-away-test.js | 3 ++- src/hooks/test/use-key-press-test.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hooks/test/use-click-away-test.js b/src/hooks/test/use-click-away-test.js index 19740dae..a163ae35 100644 --- a/src/hooks/test/use-click-away-test.js +++ b/src/hooks/test/use-click-away-test.js @@ -12,7 +12,8 @@ describe('useClickAway', () => { // Create a fake component to mount in tests that uses the hook function FakeComponent({ enabled = true }) { const myRef = useRef(); - useClickAway(myRef, handler, { enabled }); + const hookOpts = enabled === true ? undefined : { enabled }; + useClickAway(myRef, handler, hookOpts); return (
diff --git a/src/hooks/test/use-focus-away-test.js b/src/hooks/test/use-focus-away-test.js index 3beec103..cfa1bfc0 100644 --- a/src/hooks/test/use-focus-away-test.js +++ b/src/hooks/test/use-focus-away-test.js @@ -12,7 +12,8 @@ describe('useFocusAway', () => { // Create a fake component to mount in tests that uses the hook function FakeComponent({ enabled = true }) { const myRef = useRef(); - useFocusAway(myRef, handler, { enabled }); + const hookOpts = enabled === true ? undefined : { enabled }; + useFocusAway(myRef, handler, hookOpts); return (
diff --git a/src/hooks/test/use-key-press-test.js b/src/hooks/test/use-key-press-test.js index 70880e8b..408a866d 100644 --- a/src/hooks/test/use-key-press-test.js +++ b/src/hooks/test/use-key-press-test.js @@ -17,7 +17,8 @@ describe('useKeyPress', () => { // Create a fake component to mount in tests that uses the hook function FakeComponent({ keys = defaultKeys, enabled = true }) { const myRef = useRef(); - useKeyPress(keys, handler, { enabled }); + const hookOpts = enabled === true ? undefined : { enabled }; + useKeyPress(keys, handler, hookOpts); return (