|
1 | 1 | import React from 'react';
|
2 |
| -import { render, screen } from '@testing-library/react'; |
| 2 | +import { render, screen, fireEvent } from '@testing-library/react'; |
3 | 3 | import user from '@testing-library/user-event';
|
4 | 4 | import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
|
5 | 5 | import Action from '../components/Action';
|
@@ -58,13 +58,17 @@ describe('unit testing for Action.tsx', () => {
|
58 | 58 | render(<Action {...props} />);
|
59 | 59 | expect(screen.getAllByRole('button')[0]).toHaveTextContent('NO TIME');
|
60 | 60 | });
|
61 |
| - }); |
62 | 61 |
|
63 |
| - describe('When actualDuration exceeds 60', () => { |
64 |
| - test('Time should be formatted correctly', () => { |
| 62 | + test('When actualDuration exceeds 60, time should be formatted correctly', () => { |
65 | 63 | props.componentData.actualDuration = 75;
|
66 | 64 | render(<Action {...props} />);
|
67 | 65 | expect(screen.getAllByRole('button')[0]).toHaveTextContent('+01:15.00');
|
68 | 66 | });
|
| 67 | + |
| 68 | + test('Using the ArrowUp key on Action snapshot should trigger handleOnKeyDown', () => { |
| 69 | + render(<Action {...props} />); |
| 70 | + fireEvent.keyDown(screen.getByRole('presentation'), {key: 'ArrowUp', code: 'ArrowUp', charCode: 38}); |
| 71 | + expect(props.handleOnkeyDown).toHaveBeenCalled();; |
| 72 | + }); |
69 | 73 | });
|
70 | 74 | });
|
0 commit comments