Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-05-13 19:00:42 +02:00
parent a58c52631e
commit cb3a900d39
639 changed files with 1185 additions and 887 deletions

View File

@ -5,30 +5,30 @@ import { vi } from 'vitest';
const api = await vi.importActual('../index') as Record<string, Function>;
let mocks: Array<Function> = [];
export const __stub = (func: (mock: any) => void) => mocks.push(func);
export const __clear = (): Function[] => mocks = [];
const __stub = (func: (mock: any) => void) => mocks.push(func);
const __clear = (): Function[] => mocks = [];
// const setupMock = (axios: AxiosInstance) => {
// const mock = new MockAdapter(axios, { onNoMatch: 'throwException' });
// mocks.map(func => func(mock));
// };
export const staticClient = api.staticClient;
const staticClient = api.staticClient;
export const getLinks = (response: Response): LinkHeader =>
const getLinks = (response: Response): LinkHeader =>
new LinkHeader(response.headers?.get('link') || undefined);
export const getNextLink = (response: Response) => {
const getNextLink = (response: Response) => {
const nextLink = new LinkHeader(response.headers?.get('link') || undefined);
return nextLink.refs.find(link => link.rel === 'next')?.uri;
};
export const getPrevLink = (response: Response) => {
const getPrevLink = (response: Response) => {
const prevLink = new LinkHeader(response.headers?.get('link') || undefined);
return prevLink.refs.find(link => link.rel === 'prev')?.uri;
};
export const baseClient = (...params: any[]) => {
const baseClient = (...params: any[]) => {
const axios = api.baseClient(...params);
// setupMock(axios);
return axios;
@ -39,3 +39,5 @@ export default (...params: any[]) => {
// setupMock(axios);
return axios;
};
export { __stub, __clear, staticClient, getLinks, getNextLink, getPrevLink, baseClient };