wundertec-core
Version:
Librería estándar de utilidades e integraciones AWS + helpers generales
24 lines (21 loc) • 726 B
text/typescript
import axios, { AxiosInstance } from "axios";
import { AxiosClient } from "../../src/http/axiosClient";
describe("AxiosClient", () => {
let instance: AxiosInstance;
beforeEach(() => {
instance = {
get: jest.fn(),
post: jest.fn(),
put: jest.fn(),
delete: jest.fn(),
defaults: {},
} as any;
jest.spyOn(axios, "create").mockReturnValue(instance);
});
it("get() should return data", async () => {
(instance.get as jest.Mock).mockResolvedValue({ data: { foo: "bar" } });
const client = new AxiosClient({ timeout: 1000 });
await expect(client.get("/test")).resolves.toEqual({ foo: "bar" });
expect(instance.get).toHaveBeenCalledWith("/test", undefined);
});
});