Skip to content

Commit

Permalink
Add unit test for Share control + dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
oo-bldrs committed Feb 23, 2023
1 parent 6233968 commit f03ad1d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Components/ShareControl.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import {fireEvent, render, renderHook, waitFor} from '@testing-library/react'
import ShareControl from './ShareControl'
import {MockComponent} from '../__mocks__/MockComponent'
import useStore from '../store/useStore'


describe('ShareControl', () => {
it('renders the dialog in the document', () => {
const {getByTitle} = render(<ShareControl/>, {
wrapper: MockComponent,
})
const component = getByTitle('Share')
expect(component).toBeInTheDocument()
})

it('updates the title when the dialog is open', async () => {
const {result} = renderHook(() => useStore((state) => state.setViewerStore))
result.current({
clipper: {
planes: [],
},
})

const {getByTitle} = render(<ShareControl/>, {
wrapper: MockComponent,
})

const button = getByTitle('Share')
fireEvent.click(button)

await(waitFor(() => expect(document.title).toBe('Share IFC Model — BLDRS')))
})
})

0 comments on commit f03ad1d

Please sign in to comment.