-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
24 additions
and
142 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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ import { renderHook } from '@testing-library/react'; | |
import * as auth0 from '@auth0/auth0-react'; | ||
|
||
import useSession from '@/hooks/useSession'; | ||
import * as helpers_env from '@/helpers/env'; | ||
|
||
jest.mock('next/navigation'); | ||
|
||
|
@@ -13,14 +12,10 @@ jest.mock('@auth0/auth0-react', () => ({ | |
|
||
jest.mock('@/helpers/env', () => ({ | ||
__esModule: true, | ||
get IS_DEMO_PLAN() { | ||
return false; | ||
}, | ||
})); | ||
|
||
describe('useSession', () => { | ||
beforeEach(() => { | ||
jest.spyOn(helpers_env, 'IS_DEMO_PLAN', 'get').mockReturnValue(false); | ||
jest.spyOn(auth0, 'useAuth0').mockReturnValue({ | ||
isAuthenticated: false, | ||
} as auth0.Auth0ContextInterface<auth0.User>); | ||
|
@@ -53,17 +48,4 @@ describe('useSession', () => { | |
expect(result.current.accessToken).toEqual('accessToken'); | ||
expect(result.current.user).toEqual(user); | ||
}); | ||
|
||
it('returns fake user when staging', async () => { | ||
jest.spyOn(helpers_env, 'IS_DEMO_PLAN', 'get').mockReturnValue(true); | ||
const { result } = renderHook(() => useSession()); | ||
|
||
expect(result.current.user).toEqual({ | ||
email: '[email protected]', | ||
picture: '', | ||
name: 'Maffin', | ||
}); | ||
expect(result.current.isAuthenticated).toBe(true); | ||
expect(result.current.isLoading).toBe(false); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -2,8 +2,6 @@ import React from 'react'; | |
import { useAuth0 } from '@auth0/auth0-react'; | ||
import type { User, Auth0ContextInterface } from '@auth0/auth0-react'; | ||
|
||
import { IS_DEMO_PLAN } from '@/helpers/env'; | ||
|
||
const emptyUser: User = { | ||
name: '', | ||
email: '', | ||
|
@@ -39,10 +37,8 @@ export default function useSession(): SessionReturn { | |
return { | ||
...auth0, | ||
accessToken, | ||
isAuthenticated: IS_DEMO_PLAN ? true : auth0.isAuthenticated, | ||
isLoading: IS_DEMO_PLAN ? false : auth0.isLoading, | ||
user: IS_DEMO_PLAN | ||
? { name: 'Maffin', email: '[email protected]', picture: '' } | ||
: auth0.user || emptyUser, | ||
isAuthenticated: auth0.isAuthenticated, | ||
isLoading: auth0.isLoading, | ||
user: auth0.user || emptyUser, | ||
}; | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default as GDriveBookStorage } from './GDriveBookStorage'; | ||
export { default as DemoBookStorage } from './DemoBookStorage'; | ||
export { default as FreeBookStorage } from './FreeBookStorage'; |