You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test coverage possible via hooks, use @testing-library/react-hooks.
useAuth()
test error when not inside provider. Potentially refactor to checkContext function and isolate that test.
Mock @aws-amplify/Auth and test value returned is equal to mocked value.
useAuthProvider()
mock Auth with jest.fn() for each method called
test each method is called when the authProvider method is called
login - test Auth.signIn called with username & password
login - test Auth.federatedSignIn called with provider property
getPermissions - test Promise resolves to [claims: {}, identityId: ""] based on mocks
useUser()
test undefined return in unauthenticated state
mock signIn and check returned user value is {}
mock signOut and check returned value is undefined
note: @aws-amplify/Hub may not need to be mocked as it's a local event bus
The text was updated successfully, but these errors were encountered:
mayteio
changed the title
Unit tests for <RaAmplifyAuthProvider /> & related hooks
Jest tests for <RaAmplifyAuthProvider /> & related hooks
Mar 18, 2020
Test coverage possible via hooks, use
@testing-library/react-hooks
.useAuth()
checkContext
function and isolate that test.@aws-amplify/Auth
and test value returned is equal to mocked value.useAuthProvider()
Auth.signIn
called with username & passwordAuth.federatedSignIn
called withprovider
propertyuseUser()
@aws-amplify/Hub
may not need to be mocked as it's a local event busThe text was updated successfully, but these errors were encountered: