@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user