diff --git a/packages/synapse-react-client/src/mocks/MockApplicationSessionContext.tsx b/packages/synapse-react-client/src/mocks/MockApplicationSessionContext.tsx new file mode 100644 index 0000000000..0c5456dc46 --- /dev/null +++ b/packages/synapse-react-client/src/mocks/MockApplicationSessionContext.tsx @@ -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 ( + + {children} + + ) + }) diff --git a/packages/synapse-react-client/src/testutils/TestingLibraryUtils.tsx b/packages/synapse-react-client/src/testutils/TestingLibraryUtils.tsx index acc0a8685a..0a3806397c 100644 --- a/packages/synapse-react-client/src/testutils/TestingLibraryUtils.tsx +++ b/packages/synapse-react-client/src/testutils/TestingLibraryUtils.tsx @@ -5,6 +5,7 @@ import { SynapseContextType } from '../utils/context/SynapseContext' import FullContextProvider, { defaultQueryClientConfig, } from '../utils/context/FullContextProvider' +import { ApplicationSessionTestContext } from '../mocks/MockApplicationSessionContext' type RtlWrapperProps = { children?: ReactNode @@ -26,12 +27,14 @@ export const createWrapperAndQueryClient = ( return { wrapperFn: function RtlWrapper({ children }: RtlWrapperProps) { return ( - - {children} - + + + {children} + + ) }, queryClient: queryClient,