Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

browser-preview-button.test.tsx

32 lines1.4 KB

1import type { ReactNode } from "react";
2import { renderToStaticMarkup } from "react-dom/server";
3import { initializeGT } from "gt-react-native/testing";
4import { afterAll, beforeAll, expect, it, vi } from "vite-plus/test";
5​
6import ru from "../../i18n/translations/ru.json";
7​
8import { BrowserPreviewButton } from "./browser-preview-button";
9​
10vi.mock("react-native", () => ({
11 Pressable: ({ children }: { children?: ReactNode }) => <>{children}</>,
12 View: ({ children }: { children?: ReactNode }) => <>{children}</>,
13}));
14vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
15vi.mock("../../components/ui/AppText", () => ({
16 AppText: ({ children }: { children?: ReactNode }) => <>{children}</>,
17}));
18​
19// The testing entry renders this catalog with no provider and no native module.
20beforeAll(() => initializeGT({ defaultLocale: "en", locale: "ru", translations: { ru } }));
21afterAll(() => initializeGT());
22​
23// Russian puts 21 in the plural category of 1, so the pill picks its wording from the count itself.
24it.each([
25 [1, "Открыта одна вкладка"],
26 [21, "Открыто вкладок: 21"],
27 [22, "Открыто вкладок: 22"],
28])("labels %i open tabs in the expanded Russian pill", (count, label) => {
29 expect(
30 renderToStaticMarkup(<BrowserPreviewButton count={count} compact={false} onPress={() => {}} />),
31 ).toBe(label);
32});