Skip to content

Commit b75b7e4

Browse files
committed
fix: use tsc for mobile lint-staged + fix 7 test file TS errors
- Replace eslint with tsc --noEmit in lint-staged for mobile (same as extension fix) - Fix DonateScreen.test.tsx: add lastResult to mock type - Fix useDeepLink.test.ts: spread, mockGetInitialURL, mockAddEventListener types - Fix ErrorBoundary.test.tsx: info possibly undefined after array access
1 parent ddaca76 commit b75b7e4

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

mobile/__tests__/DonateScreen.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jest.mock("../hooks/useBiometricAuth", () => {
5252
label: "Biometrics",
5353
authenticate: jest.fn(),
5454
refresh: jest.fn(),
55+
lastResult: null as { success: boolean; error?: string } | null,
5556
};
5657
return {
5758
__esModule: true,
@@ -75,6 +76,7 @@ const bioMock = useBiometricAuth as unknown as () => {
7576
enrolled: boolean;
7677
label: string;
7778
authenticate: jest.Mock;
79+
lastResult: { success: boolean; error?: string } | null;
7880
};
7981

8082
// Stub theme so the donate screen doesn't pull in the full

mobile/__tests__/useDeepLink.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import { renderHook, act } from "@testing-library/react-native";
66

77
const mockPush = jest.fn();
8-
const mockGetInitialURL = jest.fn(() => Promise.resolve(null));
9-
const mockAddEventListener = jest.fn(() => ({ remove: jest.fn() }));
8+
const mockGetInitialURL = jest.fn<Promise<string | null>, []>(() => Promise.resolve(null));
9+
const mockAddEventListener = jest.fn(() => ({ remove: jest.fn() })) as jest.Mock;
1010

1111
jest.mock("expo-router", () => ({
1212
useRouter: () => ({ push: mockPush }),
1313
}));
1414

1515
jest.mock("expo-linking", () => ({
1616
getInitialURL: () => mockGetInitialURL(),
17-
addEventListener: (...args: unknown[]) => mockAddEventListener(...args),
17+
addEventListener: (...args: any[]) => mockAddEventListener(...args),
1818
parse: (url: string) => {
1919
const match = url.match(/^indigopay:\/\/(.+)/);
2020
return { path: match ? match[1] : null };

mobile/components/__tests__/ErrorBoundary.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("ErrorBoundary", () => {
9696
const [error, info] = onError.mock.calls[0];
9797
expect(error).toBeInstanceOf(Error);
9898
expect(error.message).toBe("intentional render error");
99-
expect(typeof info.componentStack).toBe("string");
99+
expect(typeof info!.componentStack).toBe("string");
100100
spy.mockRestore();
101101
});
102102

@@ -111,10 +111,12 @@ describe("ErrorBoundary", () => {
111111
// the mock resolves a promise we don't observe. Verify the call
112112
// happened with the correct arguments.
113113
expect(captureExceptionMock).toHaveBeenCalledTimes(1);
114-
const [err, info] = captureExceptionMock.mock.calls[0];
114+
const call = captureExceptionMock.mock.calls[0];
115+
expect(call).toBeDefined();
116+
const [err, info] = call!;
115117
expect(err).toBeInstanceOf(Error);
116118
expect(err.message).toBe("intentional render error");
117-
expect(typeof info.componentStack).toBe("string");
119+
expect(typeof info!.componentStack).toBe("string");
118120
spy.mockRestore();
119121
});
120122

0 commit comments

Comments
 (0)