/** * @jest-environment jsdom */ // Copyright (c) 2023 Tudor Stanciu import axios from "axios"; import { TuitioClient } from "../client"; jest.mock("axios"); test("Tuitio client: successfully obtain data from getUserInfo method", async () => { (axios as jest.MockedFunction).mockResolvedValue({ data: { userId: 1, userName: "tuitio.test", firstName: "Tuitio", lastName: "Test", email: "tuitio.test@lab.com", profilePictureUrl: "https://domain/cdn/resources/test.jpg", securityStamp: "mock", creationDate: "2023-03-08T11:46:31.453", failedLoginAttempts: 0, lastLoginDate: "2023-03-27T16:09:26.283" } }); const client = new TuitioClient("https://test.com/api"); const userInfoResult = await client.getUserInfo(); expect(userInfoResult.userId).toBe(1); expect(userInfoResult.userName).toBe("tuitio.test"); });