diff --git a/app/soapbox/__mocks__/api.ts b/app/soapbox/__mocks__/api.ts index c164ba63c..060846c94 100644 --- a/app/soapbox/__mocks__/api.ts +++ b/app/soapbox/__mocks__/api.ts @@ -7,7 +7,7 @@ import type { AxiosInstance, AxiosResponse } from 'axios'; const api = jest.requireActual('../api') as Record; let mocks: Array = []; -export const __stub = (func: Function) => mocks.push(func); +export const __stub = (func: (mock: MockAdapter) => void) => mocks.push(func); export const __clear = (): Function[] => mocks = []; const setupMock = (axios: AxiosInstance) => { diff --git a/app/soapbox/api.ts b/app/soapbox/api.ts index 33cd803ad..bdcaf53d8 100644 --- a/app/soapbox/api.ts +++ b/app/soapbox/api.ts @@ -13,6 +13,8 @@ import * as BuildConfig from 'soapbox/build_config'; import { RootState } from 'soapbox/store'; import { getAccessToken, getAppToken, isURL, parseBaseURL } from 'soapbox/utils/auth'; +import type MockAdapter from 'axios-mock-adapter'; + /** Parse Link headers, mostly for pagination. @see {@link https://www.npmjs.com/package/http-link-header} @@ -90,3 +92,7 @@ export default (getState: () => RootState, authType: string = 'user'): AxiosInst return baseClient(accessToken, baseURL); }; + +// The Jest mock exports these, so they're needed for TypeScript. +export const __stub = (_func: (mock: MockAdapter) => void) => 0; +export const __clear = (): Function[] => [];