Skip to content

Commit

Permalink
Add MockResponse types
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Aug 20, 2024
1 parent 49d31cc commit bc2903d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import { AxiosAdapter, AxiosInstance, AxiosRequestConfig } from 'axios';

interface AxiosHeaders {
[key: string]: string | number | boolean | null | undefined;
}

type MockArrayResponse = [
status: number,
data?: any,
headers?: AxiosHeaders
];

type MockObjectResponse = {
status: number;
data: any;
headers?: AxiosHeaders,
config?: AxiosRequestConfig
};

type MockResponse = MockArrayResponse | MockObjectResponse;

type CallbackResponseSpecFunc = (
config: AxiosRequestConfig
) => any[] | Promise<any[]>;
) => MockResponse | Promise<MockResponse>;

type ResponseSpecFunc = <T = any>(
statusOrCallback: number | CallbackResponseSpecFunc,
data?: T,
headers?: any
headers?: AxiosHeaders
) => MockAdapter;

declare namespace MockAdapter {
Expand Down

0 comments on commit bc2903d

Please sign in to comment.