-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Even more tests #56
Even more tests #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice just some quick thoughts
src/components/Header/Header.test.js
Outdated
}); | ||
|
||
it("the hamburger button toggles the menu", async () => { | ||
act(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could try and put this act resize function in its own function since we're writing it twice - (and probably will use it more)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! Pushing this up right now. I extracted it from the tests but left it in the file (with an export), since at the moment I'm not sure where its best long-term home would be.
src/hooks/useUser.js
Outdated
@@ -1,10 +1,12 @@ | |||
import { useQuery } from '@apollo/client'; | |||
import { CURRENT_USER_QUERY } from 'queries' | |||
|
|||
export const useUser = () => { | |||
function useUser() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just something to think about, could maybe do something like:
const { data, loading } = useQuery(CURRENT_USER_QUERY);
if (!loading) {
const {currentUser} = data;
return currentUser;
}
also feel like useUser is a little weird tongue twister of a name lol, maybe we can do useCurrentUser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking! Changed the name and updated all imports. Refactored as suggested here adding in a possible error state as well:
if (!loading && !error)
Description:
Added more tests for Header, GardenList, Profile, and App components, and did some slight reformatting to standardize user flow (updated App to use useUser hook rather than getToken to determine routing).
Tests:
Most changes are made to tests themselves, but other changes are addressed by tests.
Checklist:
Please put an x in each box that you have completed