sforkowany z mirror/soapbox
MockAdapter: add types
rodzic
504693db83
commit
145c6efa4e
|
@ -7,7 +7,7 @@ import type { AxiosInstance, AxiosResponse } from 'axios';
|
||||||
const api = jest.requireActual('../api') as Record<string, Function>;
|
const api = jest.requireActual('../api') as Record<string, Function>;
|
||||||
let mocks: Array<Function> = [];
|
let mocks: Array<Function> = [];
|
||||||
|
|
||||||
export const __stub = (func: Function) => mocks.push(func);
|
export const __stub = (func: (mock: MockAdapter) => void) => mocks.push(func);
|
||||||
export const __clear = (): Function[] => mocks = [];
|
export const __clear = (): Function[] => mocks = [];
|
||||||
|
|
||||||
const setupMock = (axios: AxiosInstance) => {
|
const setupMock = (axios: AxiosInstance) => {
|
||||||
|
|
|
@ -13,6 +13,8 @@ import * as BuildConfig from 'soapbox/build_config';
|
||||||
import { RootState } from 'soapbox/store';
|
import { RootState } from 'soapbox/store';
|
||||||
import { getAccessToken, getAppToken, isURL, parseBaseURL } from 'soapbox/utils/auth';
|
import { getAccessToken, getAppToken, isURL, parseBaseURL } from 'soapbox/utils/auth';
|
||||||
|
|
||||||
|
import type MockAdapter from 'axios-mock-adapter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Parse Link headers, mostly for pagination.
|
Parse Link headers, mostly for pagination.
|
||||||
@see {@link https://www.npmjs.com/package/http-link-header}
|
@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);
|
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[] => [];
|
||||||
|
|
Ładowanie…
Reference in New Issue