Adjust testing with localization

This commit is contained in:
adilallo
2026-01-30 18:39:15 -07:00
parent 1280844706
commit ebd025fe27
23 changed files with 139 additions and 47 deletions
+23
View File
@@ -0,0 +1,23 @@
import React, { type ReactElement } from "react";
import { render, type RenderOptions } from "@testing-library/react";
import { MessagesProvider } from "../../app/contexts/MessagesContext";
import messages from "../../messages/en/index";
/**
* Custom render function that wraps components with MessagesProvider
* Use this instead of the default render from @testing-library/react
* for components that use useTranslation hook
*/
export function renderWithProviders(
ui: ReactElement,
options?: Omit<RenderOptions, "wrapper">,
) {
function Wrapper({ children }: { children: React.ReactNode }) {
return <MessagesProvider messages={messages}>{children}</MessagesProvider>;
}
return render(ui, { wrapper: Wrapper, ...options });
}
// Re-export everything from @testing-library/react for convenience
export * from "@testing-library/react";