All files / src/utils mock-utils.tsx

100% Statements 5/5
100% Branches 1/1
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      13x                       2x 2x         2x    
import type { AxiosResponse, AxiosResponseHeaders } from "axios";
 
// Generic mock response creator that works with any data type
export const createMockAxiosResponse = <T,>(data: T): AxiosResponse<T> => ({
  data,
  status: 200,
  statusText: "OK",
  headers: {} as AxiosResponseHeaders,
  config: {
    headers: {} as AxiosResponseHeaders,
  } as any,
});
 
// Mock for error responses
export const createMockAxiosError = (message: string, status: number = 400) => {
  const error = new Error(message) as any;
  error.response = {
    data: { message },
    status,
    statusText: "Error",
  };
  return error;
};