test(app): fix pane test mocks

This commit is contained in:
Mohamed Boudra
2026-05-31 12:45:29 +07:00
parent 0a960f9ae0
commit de162b98d4
3 changed files with 30 additions and 9 deletions
@@ -164,7 +164,16 @@ vi.mock("react-native", () => {
});
});
return { Pressable: MockPressable, Text: MockText, TextInput: MockTextInput, View: MockView };
return {
Platform: {
OS: "web",
select: (options: Record<string, unknown>) => options.web ?? options.default,
},
Pressable: MockPressable,
Text: MockText,
TextInput: MockTextInput,
View: MockView,
};
});
vi.mock("react-native-unistyles", () => ({
+16 -8
View File
@@ -32,7 +32,7 @@ const { queryState, theme } = vi.hoisted(() => ({
},
theme: {
spacing: { 1: 4, 2: 8, 3: 12, 4: 16 },
fontSize: { sm: 13 },
fontSize: { sm: 13, code: 13 },
colors: {
destructive: "#f43f5e",
foreground: "#fff",
@@ -67,13 +67,17 @@ vi.mock("react-native", () => {
children,
);
});
const MockText = ({
children,
style,
}: {
children?: React.ReactNode;
style?: React.CSSProperties;
}) => React.createElement("span", { style }, children);
const flattenMockStyle = (value: unknown): React.CSSProperties => {
if (Array.isArray(value)) {
return value.reduce<React.CSSProperties>(
(acc, item) => Object.assign(acc, flattenMockStyle(item)),
{},
);
}
return (value as React.CSSProperties | null | undefined) ?? {};
};
const MockText = ({ children, style }: { children?: React.ReactNode; style?: unknown }) =>
React.createElement("span", { style: flattenMockStyle(style) }, children);
const MockPressable = ({
children,
disabled,
@@ -170,6 +174,10 @@ vi.mock("react-native-unistyles", () => ({
useUnistyles: () => ({ theme }),
}));
vi.mock("@/styles/syntax-token-styles", () => ({
syntaxTokenStyleFor: () => ({ color: "#fff" }),
}));
vi.mock("@/attachments/use-attachment-preview-url", () => ({
useAttachmentPreviewUrl: (metadata: unknown) => (metadata ? "blob:preview" : null),
}));
@@ -177,6 +177,10 @@ vi.mock("react-native", () => {
return {
ActivityIndicator: () => React.createElement("span", { "data-testid": "activity" }),
Platform: {
OS: "web",
select: (options: Record<string, unknown>) => options.web ?? options.default,
},
Pressable: MockPressable,
ScrollView: MockView,
Text: MockText,