-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathCreateCollectionSelectorModal.spec.tsx
More file actions
56 lines (49 loc) · 1.77 KB
/
CreateCollectionSelectorModal.spec.tsx
File metadata and controls
56 lines (49 loc) · 1.77 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
56
import { renderWithProviders } from 'specs/utils'
import { CreateCollectionSelectorModal } from './CreateCollectionSelectorModal'
import { Props } from './CreateCollectionSelectorModal.types'
import { CREATE_BUTTON_TEST_ID } from './constants'
import userEvent from '@testing-library/user-event'
export function renderWorldContributorTab(props: Partial<Props>) {
return renderWithProviders(
<CreateCollectionSelectorModal
onCreateCollection={jest.fn()}
onCreateThirdPartyCollection={jest.fn()}
metadata={{}}
name="aName"
onClose={jest.fn()}
{...props}
/>
)
}
describe('when clicking on the create collection button', () => {
let renderedComponent: ReturnType<typeof renderWorldContributorTab>
let onCreateCollection: jest.Mock
let onCreateThirdPartyCollection: jest.Mock
beforeEach(() => {
onCreateCollection = jest.fn()
onCreateThirdPartyCollection = jest.fn()
renderedComponent = renderWorldContributorTab({
onCreateCollection,
onCreateThirdPartyCollection
})
})
describe('and the button belongs to the classic collections', () => {
let createButton: HTMLElement
beforeEach(() => {
createButton = renderedComponent.getAllByTestId(CREATE_BUTTON_TEST_ID)[0]
userEvent.click(createButton)
})
it('should call the onCreateCollection prop method', () => {
expect(onCreateCollection).toHaveBeenCalled()
})
})
describe('and the button belongs to the linked collections', () => {
beforeEach(() => {
const createButton = renderedComponent.getAllByTestId(CREATE_BUTTON_TEST_ID)[1]
userEvent.click(createButton)
})
it('should call the onCreateThirdPartyCollection method prop', () => {
expect(onCreateThirdPartyCollection).toHaveBeenCalled()
})
})
})