Skip to content
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

chore: clean up mock auth client #5911

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/testing/src/web/MockProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from 'react'

import type { AuthContextInterface } from '@redwoodjs/auth'
import { AuthProvider } from '@redwoodjs/auth'
import { AuthClient } from '@redwoodjs/auth/src/authClients'
import { LocationProvider } from '@redwoodjs/router'
import { RedwoodProvider } from '@redwoodjs/web'
import { RedwoodApolloProvider } from '@redwoodjs/web/apollo'
Expand All @@ -20,6 +21,7 @@ const {
default: UserRouterWithRoutes,
} = require('~__REDWOOD__USER_ROUTES_FOR_MOCK')

// TODO: make this AuthContextInterface & the below AuthClient more composable/extendable|"overwriteable"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this TODO is more of a nice to have, doesn't need to happen in this PR (also might change somewhat depending on auth changes in PRs like #5985 )

const fakeUseAuth = (): AuthContextInterface => ({
loading: false,
isAuthenticated: false,
Expand All @@ -40,17 +42,20 @@ const fakeUseAuth = (): AuthContextInterface => ({
hasError: false,
})

export const mockAuthClient = {
export const mockAuthClient: AuthClient = {
restoreAuthState: () => {},
login: () => {},
login: async () => {},
logout: () => {},
signup: () => {},
getToken: () => {
getToken: async () => {
return 'token'
},
getUserMetadata: () => {
getUserMetadata: async () => {
return mockedUserMeta.currentUser
},
forgotPassword: () => {},
resetPassword: () => {},
validateResetToken: () => {},
client: 'Custom',
type: 'custom',
}
Expand Down