Skip to content

Commit e727a70

Browse files
test(mobile): mock shared project actions in settings tests
1 parent 82bea80 commit e727a70

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ vi.mock("../../state/use-atom-command", () => ({
5959
vi.mock("../threads/thread-settings-options", () => ({ RUNTIME_MODE_CHOICES: [] }));
6060
vi.mock("../../components/ui/ScreenScrollView", () => ({ ScreenScrollView: Children }));
6161
vi.mock("../../components/ui/AppText", () => ({ AppText: Children }));
62+
vi.mock("../../components/ui/Button", () => ({
63+
Button: ({
64+
label,
65+
disabled,
66+
onPress,
67+
}: {
68+
label: string;
69+
disabled?: boolean;
70+
onPress: () => void;
71+
}) => (
72+
<button disabled={disabled} onClick={onPress}>
73+
{label}
74+
</button>
75+
),
76+
}));
6277
vi.mock("./components/SettingsScreen", () => ({ SettingsScreen: Children }));
6378
vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
6479
AndroidSettingsEnvironmentFilter: () => null,
@@ -272,15 +287,15 @@ describe.each([
272287
}));
273288
act(() => root.render(<Screen />));
274289

275-
await act(async () => button("Use environment defaults").click());
290+
await act(async () => button("Use defaults").click());
276291

277292
expectFailures();
278293
expect(button(label).getAttribute("aria-checked")).toBe("true");
279-
expect(button("Use environment defaults").disabled).toBe(false);
294+
expect(button("Use defaults").disabled).toBe(false);
280295

281296
mocks.alert.mockClear();
282297
mocks.updateSettings.mockResolvedValue(AsyncResult.success(undefined));
283-
await act(async () => button("Use environment defaults").click());
298+
await act(async () => button("Use defaults").click());
284299
expect(mocks.updateSettings).toHaveBeenCalledTimes(6);
285300
expect(mocks.alert).not.toHaveBeenCalled();
286301
expect(button(label).getAttribute("aria-checked")).toBe("true");

0 commit comments

Comments
 (0)