@@ -3,7 +3,7 @@ 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' ;
6
- import { changeView } from '../actions/actions' ;
6
+ import { changeView , changeSlider } from '../actions/actions' ;
7
7
8
8
// @ts -ignore
9
9
Action . cleanTime = jest . fn ( ) . mockReturnValue ( ) ;
@@ -69,25 +69,32 @@ describe('unit testing for Action.tsx', () => {
69
69
test ( 'Using the ArrowUp key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
70
70
render ( < Action { ...props } /> ) ;
71
71
fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'ArrowUp' , code : 'ArrowUp' , charCode : 38 } ) ;
72
- expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ; ;
72
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
73
73
} ) ;
74
74
75
75
test ( 'Using the ArrowDown key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
76
76
render ( < Action { ...props } /> ) ;
77
77
fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'ArrowDown' , code : 'ArrowDown' , charCode : 40 } ) ;
78
- expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ; ;
78
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
79
79
} ) ;
80
80
81
81
test ( 'Using the Enter key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
82
82
render ( < Action { ...props } /> ) ;
83
83
fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'Enter' , code : 'Enter' , charCode : 13 } ) ;
84
- expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ; ;
84
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
85
85
} ) ;
86
86
87
87
test ( 'Clicking the snapshot should trigger onClick' , ( ) => {
88
88
render ( < Action { ...props } /> ) ;
89
89
fireEvent . click ( screen . getByRole ( 'presentation' ) ) ;
90
90
expect ( props . dispatch ) . toHaveBeenCalledWith ( changeView ( 2 ) ) ; ;
91
91
} ) ;
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
+ } ) ;
92
99
} ) ;
93
100
} ) ;
0 commit comments