|
1 | | -import { render } from '@testing-library/react'; |
| 1 | +import { fireEvent, render } from '@testing-library/react'; |
2 | 2 | import { axe } from 'jest-axe'; |
3 | 3 |
|
4 | 4 | import { createWizardFlow, useWizardFlow } from 'index'; |
@@ -43,15 +43,41 @@ describe('#react-wizard-flow', () => { |
43 | 43 | expect(results).toHaveNoViolations(); |
44 | 44 | }); |
45 | 45 |
|
46 | | - it('should have functioning transitions', () => { |
47 | | - expect(true).toBe(true); |
| 46 | + it('should have functioning transitions', async () => { |
| 47 | + const { container, getByText } = render( |
| 48 | + <TestWizardFlow.Provider initialStep={TestSteps.step1} steps={STEPS} />, |
| 49 | + ); |
| 50 | + expect(getByText('Step 1')).toBeVisible(); |
| 51 | + fireEvent.click(getByText("To Step 2")); |
| 52 | + expect(getByText('Step 2')).toBeVisible(); |
| 53 | + const results = await axe(container); |
| 54 | + expect(results).toHaveNoViolations(); |
48 | 55 | }); |
49 | 56 |
|
50 | | - it('should have a functioning close callback', () => { |
51 | | - expect(true).toBe(true); |
| 57 | + it('should have a functioning close callback', async () => { |
| 58 | + const handleClose = jest.fn(); |
| 59 | + const { container, getByText } = render( |
| 60 | + <TestWizardFlow.Provider initialStep={TestSteps.step1} steps={STEPS} onClose={handleClose} />, |
| 61 | + ); |
| 62 | + expect(getByText('Step 1')).toBeVisible(); |
| 63 | + expect(handleClose.mock.calls).toHaveLength(0); |
| 64 | + fireEvent.click(getByText("Close")); |
| 65 | + expect(getByText('Step 1')).toBeVisible(); |
| 66 | + expect(handleClose.mock.calls).toHaveLength(1); |
| 67 | + const results = await axe(container); |
| 68 | + expect(results).toHaveNoViolations(); |
52 | 69 | }); |
53 | 70 |
|
54 | 71 | it('should not blow up without a close callback', () => { |
55 | | - expect(true).toBe(true); |
| 72 | + expect(async () => { |
| 73 | + const { container, getByText } = render( |
| 74 | + <TestWizardFlow.Provider initialStep={TestSteps.step1} steps={STEPS} />, |
| 75 | + ); |
| 76 | + expect(getByText('Step 1')).toBeVisible(); |
| 77 | + fireEvent.click(getByText("Close")); |
| 78 | + expect(getByText('Step 1')).toBeVisible(); |
| 79 | + const results = await axe(container); |
| 80 | + expect(results).toHaveNoViolations(); |
| 81 | + }).not.toThrow() |
56 | 82 | }); |
57 | 83 | }); |
0 commit comments