forked from Sage-Bionetworks/synapse-web-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a mock application session context (provider) to our standard tes…
…ting library wrapper
- Loading branch information
1 parent
c2184ef
commit 5f065d6
Showing
2 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/synapse-react-client/src/mocks/MockApplicationSessionContext.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react' | ||
import { | ||
ApplicationSessionContextProvider, | ||
ApplicationSessionContextType, | ||
} from '../utils/AppUtils/session/ApplicationSessionContext' | ||
export const MOCK_CLEAR_SESSION = jest.fn() | ||
|
||
export const MOCK_REFRESH_SESSION = jest.fn() | ||
|
||
export const MOCK_CONTEXT_VALUE: ApplicationSessionContextType = { | ||
clearSession: MOCK_CLEAR_SESSION, | ||
refreshSession: MOCK_REFRESH_SESSION, | ||
hasInitializedSession: false, | ||
isLoadingSSO: false, | ||
} | ||
|
||
export const MOCK_CONTEXT = React.createContext(MOCK_CONTEXT_VALUE) | ||
|
||
/** | ||
* Full context object with default values for testing. | ||
* | ||
* If using @testing-library/react, see {@link TestingLibraryUtils#createWrapper} | ||
*/ | ||
export const ApplicationSessionTestContext = jest | ||
.fn() | ||
.mockImplementation(({ children }) => { | ||
return ( | ||
<ApplicationSessionContextProvider context={MOCK_CONTEXT_VALUE}> | ||
{children} | ||
</ApplicationSessionContextProvider> | ||
) | ||
}) |
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