aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils/index.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-26 21:55:55 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:15:27 +0100
commit3ab9f0423e97af63da4bf6a13ffd786955bd5b3b (patch)
tree53866337f2e2b0bd47ada82f0f35799595663108 /tests/utils/index.tsx
parent795b92cc1a168c48c7710ca6e0e1ef5974013d95 (diff)
refactor(hooks,providers): rewrite useAckee hook and AckeeProvider
Diffstat (limited to 'tests/utils/index.tsx')
-rw-r--r--tests/utils/index.tsx36
1 files changed, 24 insertions, 12 deletions
diff --git a/tests/utils/index.tsx b/tests/utils/index.tsx
index 1bcea8e..8766318 100644
--- a/tests/utils/index.tsx
+++ b/tests/utils/index.tsx
@@ -1,7 +1,11 @@
-import { render, RenderOptions } from '@testing-library/react';
+import {
+ render as rtlRender,
+ type RenderOptions,
+} from '@testing-library/react';
import { ThemeProvider } from 'next-themes';
-import { FC, ReactElement, ReactNode } from 'react';
+import type { FC, ReactElement, ReactNode } from 'react';
import { IntlProvider } from 'react-intl';
+import { AckeeProvider } from '../../src/utils/providers';
type ProvidersConfig = {
children: ReactNode;
@@ -18,13 +22,20 @@ type CustomRenderOptions = {
*
* @returns A component wrapped Intl and Theme providers.
*/
-const AllTheProviders: FC<ProvidersConfig> = ({ children, locale = 'en' }) => {
- return (
- <IntlProvider locale={locale}>
- <ThemeProvider>{children}</ThemeProvider>
- </IntlProvider>
- );
-};
+const AllTheProviders: FC<ProvidersConfig> = ({ children, locale = 'en' }) => (
+ <IntlProvider locale={locale}>
+ <ThemeProvider>
+ <AckeeProvider
+ domainId="any-id"
+ server="https://example.test"
+ storageKey="ackee"
+ tracking="full"
+ >
+ {children}
+ </AckeeProvider>
+ </ThemeProvider>
+ </IntlProvider>
+);
/**
* Render a component with all the providers.
@@ -33,11 +44,12 @@ const AllTheProviders: FC<ProvidersConfig> = ({ children, locale = 'en' }) => {
* @param {CustomRenderOptions} [options] - An object of render options and providers options.
* @returns A React component wrapped with all the providers.
*/
-const customRender = (ui: ReactElement, options?: CustomRenderOptions) =>
- render(ui, {
+const render = (ui: ReactElement, options?: CustomRenderOptions) =>
+ rtlRender(ui, {
wrapper: (props) => <AllTheProviders {...props} {...options?.providers} />,
...options?.testingLibrary,
});
+/* eslint-disable import/export */
export * from '@testing-library/react';
-export { customRender as render };
+export { render };