-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathusers-list-rcc.test.tsx
More file actions
42 lines (38 loc) · 1013 Bytes
/
users-list-rcc.test.tsx
File metadata and controls
42 lines (38 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { render, screen, waitFor, act } from "@testing-library/react";
import { MockedProvider } from "@apollo/client/testing/react";
import { UsersListContainer } from "./users-list-rcc";
import { UsersDocument } from "./queries/users.graphql.interface";
const createMocks = () => [
{
request: {
query: UsersDocument,
},
result: {
data: {
users: {
data: [
{
id: "1",
name: "Test User",
},
],
},
},
},
},
];
describe("UsersList (React Client Component)", () => {
it("should render loading state and then list of users", async () => {
await act(async () => {
render(
<MockedProvider mocks={createMocks()}>
<UsersListContainer />
</MockedProvider>,
);
});
expect(screen.getByText(/Loading users.../i)).toBeInTheDocument();
await waitFor(() => {
expect(screen.getByText(/Test User/i)).toBeInTheDocument();
});
});
});