mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-29 12:42:57 +00:00
test(app): fix pane test mocks
This commit is contained in:
@@ -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", () => ({
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user