Skip to content

Commit

Permalink
Add TabbedDialog.test.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-mayrgundter committed Aug 17, 2023
1 parent 4f9fa9b commit 4694f22
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Components/TabbedDialog.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'
import {render, screen, fireEvent} from '@testing-library/react'
import TabbedDialog from './TabbedDialog'


describe('TabbedDialog', () => {
it('', () => {
const cb1 = jest.fn()
const cb2 = jest.fn()
const cb3 = jest.fn()
render(
<TabbedDialog
tabLabels={['Explore', 'Open', 'Save']}
headerLabels={['Explore Sample Projects', 'Open Project', 'Save Project']}
contentComponents={[
(<p key='1'>{'A content'}</p>),
(<p key='2'>{'B content'}</p>),
(<p key='3'>{'C content'}</p>),
]}
actionCbs={[cb1, cb2, cb3]}
actionButtonLabels={['A OK', 'B OK', 'C OK']}
isDialogDisplayed={true}
setIsDialogDisplayed={jest.fn()}
/>)

fireEvent.click(screen.getByText('A OK'))
expect(cb1.mock.calls.length).toBe(1)
expect(cb2.mock.calls.length).toBe(0)
expect(cb3.mock.calls.length).toBe(0)

fireEvent.click(screen.getByText('Open'))
fireEvent.click(screen.getByText('B OK'))
expect(cb1.mock.calls.length).toBe(1)
expect(cb2.mock.calls.length).toBe(1)
expect(cb3.mock.calls.length).toBe(0)

fireEvent.click(screen.getByText('Save'))
fireEvent.click(screen.getByText('C OK'))
expect(cb1.mock.calls.length).toBe(1)
expect(cb2.mock.calls.length).toBe(1)
expect(cb3.mock.calls.length).toBe(1)
})
})

0 comments on commit 4694f22

Please sign in to comment.