Skip to content

Commit

Permalink
Fix test coverage miss for event hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lyzadanger committed Mar 10, 2023
1 parent b1a8a22 commit db2a927
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/hooks/test/use-click-away-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div ref={myRef}>
<button>Hi</button>
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/test/use-focus-away-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div ref={myRef}>
<button>Hi</button>
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/test/use-key-press-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div ref={myRef}>
<button>Hi</button>
Expand Down

0 comments on commit db2a927

Please sign in to comment.