forked from artsy/reaction
/
GeneToolTip.test.tsx
56 lines (51 loc) · 1.65 KB
/
GeneToolTip.test.tsx
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
56
import { SystemContextProvider } from "Artsy"
import { FollowGeneButton } from "Components/FollowButton/FollowGeneButton"
import { Genes } from "Components/Publishing/Fixtures/Components"
import { wrapperWithContext } from "Components/Publishing/Fixtures/Helpers"
import { mount } from "enzyme"
import "jest-styled-components"
import PropTypes from "prop-types"
import React from "react"
import { GeneToolTip } from "../GeneToolTip"
describe("GeneTooltip", () => {
const getWrapper = (props, context = {}) => {
return mount(
wrapperWithContext(
{
...context,
tooltipsData: {
genes: [props.gene],
},
},
{
tooltipsData: PropTypes.object,
onOpenAuthModal: PropTypes.func,
user: PropTypes.object,
},
<SystemContextProvider user={(context as any).user}>
<GeneToolTip gene={props.gene} />
</SystemContextProvider>
)
)
}
it("Renders gene data", () => {
const gene = Genes[0].gene
const component = getWrapper({ gene })
expect(component.text()).toMatch(gene.name)
})
describe("Open Auth Modal", () => {
it("callback gets called when followButton is clicked", () => {
const gene = Genes[0].gene
const context = {
onOpenAuthModal: jest.fn(),
user: null,
}
const component = getWrapper({ gene }, context)
component.find(FollowGeneButton).simulate("click")
const args = context.onOpenAuthModal.mock.calls[0]
expect(args[0]).toBe("signup")
expect(args[1].contextModule).toBe("intext tooltip")
expect(args[1].intent).toBe("follow gene")
})
})
})