Skip to content

Commit

Permalink
Merge pull request #452 from oo-bldrs/relocate-issue-unit-tests
Browse files Browse the repository at this point in the history
Move tests for <Issues>
  • Loading branch information
oo-bldrs committed Oct 27, 2022
2 parents 7928941 + 12c42ba commit aa900c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/Components/SideDrawer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,4 @@ describe('SideDrawer', () => {
result.current.toggleIsPropertiesOn()
})
})

it('issues id in url', async () => {
const {result} = renderHook(() => useStore((state) => state))
const extractedIssueId = '1257156364'
const {findByText} = render(<ShareMock><SideDrawerWrapper/></ShareMock>)
await act(() => {
result.current.setSelectedIssueId(Number(extractedIssueId))
result.current.turnCommentsOn()
result.current.openDrawer()
})
expect(await findByText('Local issue - some text is here to test - Id:1257156364')).toBeVisible()
// reset the store
await act(() => {
result.current.setSelectedIssueId(null)
result.current.turnCommentsOff()
})
})

it('opened via URL', async () => {
const {result} = renderHook(() => useStore((state) => state))
const {getByText} = render(
<ShareMock
initialEntries={['/v/p/index.ifc#i:2::c:-26.91,28.84,112.47,-22,16.21,-3.48']}
>
<SideDrawerWrapper/>
</ShareMock>)
expect(await getByText('Local issue 2')).toBeInTheDocument()

// reset the store
await act(() => {
result.current.setSelectedElement({})
result.current.turnCommentsOff()
})
})
})
23 changes: 23 additions & 0 deletions src/Components/issues/Issues.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ describe('IssueControl', () => {
expect(await getByText('open_workspace')).toBeVisible()
})

it('Issue rendered based on selected issue ID', async () => {
const {result} = renderHook(() => useStore((state) => state))
const extractedIssueId = '1257156364'
const {findByText} = render(<ShareMock><Issues/></ShareMock>)

await act(() => {
result.current.setSelectedIssueId(Number(extractedIssueId))
})

const expectedText = 'Local issue - some text is here to test - Id:1257156364'
expect(await findByText(expectedText)).toBeVisible()
})

it('Issue rendered based on issue ID in URL', async () => {
const {findByText} = render(
<ShareMock initialEntries={['/v/p/index.ifc#i:2::c:-26.91,28.84,112.47,-22,16.21,-3.48']}>
<Issues/>
</ShareMock>)

const expectedText = 'Local issue 2'
expect(await findByText(expectedText)).toBeVisible()
})

// XXX: Should this be split into two different tests?
it('test Loader is present if issues are null, and removed when issues set', async () => {
// Set up handler to return an empty set of issues
Expand Down

0 comments on commit aa900c3

Please sign in to comment.