-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSocialLinks.js
More file actions
55 lines (49 loc) · 1.26 KB
/
SocialLinks.js
File metadata and controls
55 lines (49 loc) · 1.26 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from "react";
import {cleanup, fireEvent, render, waitFor} from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import {MockedProvider} from "@apollo/react-testing";
import SocialLinks from "../SocialLinks";
import {LIKE_PRACTICE} from "../../../../graphql";
afterEach(cleanup);
const mockProps = {
practiceId: "aFak3ID4y0U",
upvotes: 42,
}
it("modifies upvotes when mutation is run", async () => {
let practiceLiked = false;
const likedPractice = {
data: {
updatePractice: {
__typename: "updatePracticePayload",
practice: {
__typename: "Practice",
id: "aFak3ID4y0U",
upvotes: 43,
},
},
},
};
const apolloMocks = [
{
request: {
query: LIKE_PRACTICE,
variables: {
practiceId: "aFak3ID4y0U",
upvotes: 43,
},
},
result: () => {
practiceLiked = true;
return likedPractice;
},
},
];
const {getByTestId} = render(
<MockedProvider mocks={apolloMocks}>
<SocialLinks {...mockProps} />
</MockedProvider>
);
expect(getByTestId("heartIcon"));
fireEvent.click(getByTestId("heartIcon"));
await waitFor(() => expect(practiceLiked).toBe(true));
});