Skip to content

Commit

Permalink
chore: clean up mock auth client (#5911)
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuoushub authored and jtoar committed Jul 28, 2022
1 parent 7ef3830 commit 7bb2aa8
Showing 1 changed file with 9 additions and 4 deletions.
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"
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

0 comments on commit 7bb2aa8

Please sign in to comment.