Files
twenty/front/src/testing/renderWrappers.tsx
T
Jérémy M 31145c5518 feat: align auth api with front convention (#370)
* feat: align auth api with front convention

* fix: email password auth

* fix: proper file naming

* Fix login

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-06-23 22:43:54 -07:00

45 lines
1.3 KiB
TypeScript

import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { ApolloProvider } from '@apollo/client';
import { RecoilRoot } from 'recoil';
import { DefaultLayout } from '@/ui/layout/DefaultLayout';
import { UserProvider } from '~/providers/user/UserProvider';
import { ComponentStorybookLayout } from './ComponentStorybookLayout';
import { FullHeightStorybookLayout } from './FullHeightStorybookLayout';
import { mockedClient } from './mockedClient';
export function getRenderWrapperForPage(
children: React.ReactElement,
currentPath: string,
) {
return function render() {
return (
<RecoilRoot>
<ApolloProvider client={mockedClient}>
<UserProvider>
<MemoryRouter initialEntries={[currentPath]}>
<FullHeightStorybookLayout>
<DefaultLayout>{children}</DefaultLayout>
</FullHeightStorybookLayout>
</MemoryRouter>
</UserProvider>
</ApolloProvider>
</RecoilRoot>
);
};
}
export function getRenderWrapperForComponent(children: React.ReactElement) {
return function render() {
return (
<RecoilRoot>
<ApolloProvider client={mockedClient}>
<ComponentStorybookLayout>{children}</ComponentStorybookLayout>
</ApolloProvider>
</RecoilRoot>
);
};
}