|
1 | 1 | import React from 'react'; |
2 | 2 | import Inspection from './Inspection'; |
3 | | -import { rtlRender, WithRouter, act, fireEvent, WithReduxStore, waitFor } from 'test-utils'; |
| 3 | +import { rtlRender, WithRouter, act, fireEvent, WithReduxStore, waitFor, userEvent } from 'test-utils'; |
4 | 4 | import Immutable from 'immutable'; |
5 | | -import { |
6 | | - mockAllIsIntersecting, |
7 | | - // mockIsIntersecting, |
8 | | - // intersectionMockInstance, |
9 | | -} from 'react-intersection-observer/test-utils'; |
| 5 | +import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'; |
10 | 6 |
|
11 | 7 | import configData from '../../../../../../data/mock/data/testing/testAndTag/testTagOnLoadInspection'; |
12 | 8 | import userData from '../../../../../../data/mock/data/testing/testAndTag/testTagUser'; |
@@ -262,6 +258,32 @@ describe('Inspection component', () => { |
262 | 258 | await waitFor(() => expect(queryByRole('dialog')).not.toBeInTheDocument()); |
263 | 259 | }); |
264 | 260 |
|
| 261 | + it('should dismiss dialog on `enter` keypress', async () => { |
| 262 | + const mockFn = jest.fn(); |
| 263 | + const loadConfigFn = jest.fn(); |
| 264 | + const clearSaveInspectionFn = jest.fn(); |
| 265 | + const clearAssetsFn = jest.fn(); |
| 266 | + |
| 267 | + const { getByRole, queryByRole } = setup({ |
| 268 | + actions: { |
| 269 | + loadAssetTypes: mockFn, |
| 270 | + loadInspectionConfig: loadConfigFn, |
| 271 | + clearSaveInspection: clearSaveInspectionFn, |
| 272 | + clearAssets: clearAssetsFn, |
| 273 | + }, |
| 274 | + saveInspectionSuccess: { |
| 275 | + asset_status: 'CURRENT', |
| 276 | + asset_id_displayed: 'UQL000705', |
| 277 | + user_licence_number: 'NOT LICENCED', |
| 278 | + action_date: '2022-12-12', |
| 279 | + asset_next_test_due_date: '2023Dec12', |
| 280 | + }, |
| 281 | + }); |
| 282 | + await waitFor(() => expect(getByRole('dialog')).toBeInTheDocument()); |
| 283 | + await userEvent.keyboard('{Enter}'); |
| 284 | + await waitFor(() => expect(queryByRole('dialog')).not.toBeInTheDocument()); |
| 285 | + }); |
| 286 | + |
265 | 287 | it('should show a save success for FAILED asset dialog panel', async () => { |
266 | 288 | const mockFn = jest.fn(); |
267 | 289 | const loadConfigFn = jest.fn(); |
|
0 commit comments