///
import * as React from "react";
import { User } from "../../src/components/User"
import { render, act, RenderResult } from "@testing-library/react";
import { UseQueryResult } from "react-query";
let userQueryMock: UseQueryResult;
jest.mock("../../src/queries/SampleQueries", () => {
return {
useUserQuery: jest.fn(() => (userQueryMock))
}
})
describe(" (mocked hook)", () => {
test("should render user", async () => {
userQueryMock = {
isLoading: false,
data: {
displayName: "Test user",
presence: { availability: "Available" },
jobTitle: "Developer",
photo: "mock-photo"
},
isError: false
} as UseQueryResult
let userComponent: RenderResult;
await act(async () => {
userComponent = await render();
let userDisplayName = await userComponent.findAllByText("Test user");
let availability = await userComponent.findAllByText("Available");
expect(userDisplayName.length).toBeGreaterThan(0);
expect(availability.length).toBeGreaterThan(0);
});
});
})