Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
import type { RenderOptions } from "@testing-library/react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { I18nContext } from "cozy-ui/transpiled/react/providers/I18n";
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import type { AppStore, RootState } from "../../src/app/store";
|
||||
import { setupStore } from "../../src/app/store";
|
||||
import { userData, userOrganiser } from "../../src/features/User/userDataTypes";
|
||||
|
||||
interface ExtendedRenderOptions extends Omit<RenderOptions, "queries"> {
|
||||
preloadedState?: Partial<RootState>;
|
||||
store?: AppStore;
|
||||
@@ -23,9 +21,24 @@ export function renderWithProviders(
|
||||
|
||||
const Wrapper = ({ children }: PropsWithChildren) => {
|
||||
return (
|
||||
<MemoryRouter initialEntries={["/"]}>
|
||||
<Provider store={store}>{children}</Provider>
|
||||
</MemoryRouter>
|
||||
<I18nContext.Provider
|
||||
value={{
|
||||
t: (key: string, vars?: Record<string, string>) => {
|
||||
if (vars) {
|
||||
const params = Object.entries(vars)
|
||||
.map(([k, v]) => `${k}=${v}`)
|
||||
.join(",");
|
||||
return `${key}(${params})`;
|
||||
}
|
||||
return key;
|
||||
},
|
||||
f: (date: Date, formatStr: string) => date.toString(),
|
||||
}}
|
||||
>
|
||||
<MemoryRouter initialEntries={["/"]}>
|
||||
<Provider store={store}>{children}</Provider>
|
||||
</MemoryRouter>
|
||||
</I18nContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user