moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import '@testing-library/jest-dom';
import { vi } from 'vitest';
import type { ReactNode } from 'react';
/**
* jsdom does not implement `matchMedia`; our component queries
* `prefers-reduced-motion` via plain CSS, but consumer code using matchMedia
* (existing `Pricing` component paths, etc.) still needs a shim during tests.
*/
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false,
}),
});
/**
* Mock next-intl for unit tests. The `t()` function returns the namespaced
* key (with ICU `{var}` placeholders interpolated), so tests can assert on
* deterministic strings without needing a real `messages/en.json` round-trip.
*
* BrandPersonasCard tests check persona-data text (from `_data/personas.ts`,
* not i18n) and passed-in prop overrides — never the default heading/
* subtitle from i18n — so this mock is safe.
*/
vi.mock('next-intl', () => ({
useTranslations: (namespace?: string) => {
return (key: string, params?: Record<string, string | number>) => {
const fullKey = namespace ? `${namespace}.${key}` : key;
if (!params) return fullKey;
return Object.entries(params).reduce(
(acc, [k, v]) => acc.replace(`{${k}}`, String(v)),
fullKey,
);
};
},
NextIntlClientProvider: ({ children }: { children: ReactNode }) => children,
}));