-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from jbouder/nav-fix
Fix Nav Mobile Toggling
- Loading branch information
Showing
3 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { act, renderHook } from "@testing-library/react"; | ||
import useUswds from "./use-uswds"; | ||
|
||
test("should call signIn successfully", async () => { | ||
const { result } = renderHook(() => useUswds()); | ||
|
||
await act(async () => { | ||
result.current.headerOn(document.body); | ||
}); | ||
expect(result.current.headerOn).toBeTruthy(); | ||
}); | ||
|
||
test("should call signOut successfully", async () => { | ||
const { result } = renderHook(() => useUswds()); | ||
|
||
await act(async () => { | ||
result.current.headerOff(document.body); | ||
}); | ||
expect(result.current.headerOff).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const useUswds = () => { | ||
const headerOn = async (bodyElement: HTMLElement) => { | ||
const navigation = (await import("@uswds/uswds/js/usa-header")).default; | ||
navigation.on(bodyElement); | ||
}; | ||
|
||
const headerOff = async (bodyElement: HTMLElement) => { | ||
const navigation = (await import("@uswds/uswds/js/usa-header")).default; | ||
navigation.off(bodyElement); | ||
}; | ||
|
||
return { headerOn, headerOff }; | ||
}; | ||
|
||
export default useUswds; |