diff --git a/src/Components/TabbedDialog.test.jsx b/src/Components/TabbedDialog.test.jsx new file mode 100644 index 000000000..ad5968395 --- /dev/null +++ b/src/Components/TabbedDialog.test.jsx @@ -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( + {'A content'}

), + (

{'B content'}

), + (

{'C content'}

), + ]} + 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) + }) +})