Skip to content

Commit 727765e

Browse files
committed
Create test for clicking Jump button
1 parent 05d2032 commit 727765e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/app/__tests__/action.test.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
33
import user from '@testing-library/user-event';
44
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
55
import Action from '../components/Action';
6-
import { changeView } from '../actions/actions';
6+
import { changeView, changeSlider } from '../actions/actions';
77

88
// @ts-ignore
99
Action.cleanTime = jest.fn().mockReturnValue();
@@ -69,25 +69,32 @@ describe('unit testing for Action.tsx', () => {
6969
test('Using the ArrowUp key on Action snapshot should trigger handleOnKeyDown', () => {
7070
render(<Action {...props} />);
7171
fireEvent.keyDown(screen.getByRole('presentation'), {key: 'ArrowUp', code: 'ArrowUp', charCode: 38});
72-
expect(props.handleOnkeyDown).toHaveBeenCalled();;
72+
expect(props.handleOnkeyDown).toHaveBeenCalled();
7373
});
7474

7575
test('Using the ArrowDown key on Action snapshot should trigger handleOnKeyDown', () => {
7676
render(<Action {...props} />);
7777
fireEvent.keyDown(screen.getByRole('presentation'), {key: 'ArrowDown', code: 'ArrowDown', charCode: 40});
78-
expect(props.handleOnkeyDown).toHaveBeenCalled();;
78+
expect(props.handleOnkeyDown).toHaveBeenCalled();
7979
});
8080

8181
test('Using the Enter key on Action snapshot should trigger handleOnKeyDown', () => {
8282
render(<Action {...props} />);
8383
fireEvent.keyDown(screen.getByRole('presentation'), {key: 'Enter', code: 'Enter', charCode: 13});
84-
expect(props.handleOnkeyDown).toHaveBeenCalled();;
84+
expect(props.handleOnkeyDown).toHaveBeenCalled();
8585
});
8686

8787
test('Clicking the snapshot should trigger onClick', () => {
8888
render(<Action {...props} />);
8989
fireEvent.click(screen.getByRole('presentation'));
9090
expect(props.dispatch).toHaveBeenCalledWith(changeView(2));;
9191
});
92+
93+
test('Clicking Jump button should trigger changeSlider and changeView', () => {
94+
render(<Action {...props} />);
95+
fireEvent.click(screen.getAllByRole('button')[1]);
96+
expect(props.dispatch).toHaveBeenCalledWith(changeSlider(2));
97+
expect(props.dispatch).toHaveBeenCalledWith(changeView(2));
98+
});
9299
});
93100
});

0 commit comments

Comments
 (0)