@@ -13,11 +13,10 @@ const customTabs = {
13
13
} ,
14
14
}
15
15
16
-
17
16
const customInitialState = {
18
17
main : {
19
18
port : null ,
20
- currentTab : 87 ,
19
+ currentTab : 100 ,
21
20
currentTitle : null ,
22
21
tabs : customTabs , // Replace with the actual (testing) tab data
23
22
currentTabInApp : null ,
@@ -39,9 +38,33 @@ const render = component => rtlRender(
39
38
< Provider store = { customStore } >
40
39
{ component }
41
40
</ Provider >
42
- ) ;
41
+ ) ;
42
+
43
+ describe ( 'Unit testing for MainSlider.jsx' , ( ) => {
44
+ const props = {
45
+ snapshotsLength : 1 ,
46
+ } ;
47
+
48
+ describe ( 'When user only has one snapshot to view' , ( ) => {
49
+ test ( 'Component should have min, max, value with correct values to indicate slider position for correct tab' , ( ) => {
50
+ render ( < MainSlider { ...props } /> ) ;
51
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuemin' , '0' ) ;
52
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuemax' , '0' ) ;
53
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuenow' , '0' ) ;
54
+ } ) ;
55
+ } ) ;
56
+
57
+ describe ( 'When there are multiple snapshots and we are looking in between' , ( ) => {
58
+ const props = {
59
+ snapshotsLength : 3 ,
60
+ } ;
61
+
62
+ test ( 'Component should have min, max, value with correct values to indicate slider position when there are multiple snapshots' , ( ) => {
63
+ render ( < MainSlider { ...props } /> ) ;
64
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuemax' , '2' ) ;
65
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuemin' , '0' ) ;
66
+ expect ( screen . getByRole ( 'slider' ) ) . toHaveAttribute ( 'aria-valuenow' , '0' )
67
+ } ) ;
68
+ } ) ;
43
69
44
- jest . mock ( 'react-redux' , ( ) => ( {
45
- ...jest . requireActual ( 'react-redux' ) , // Use the actual react-redux module except for the functions you want to mock
46
- useDispatch : jest . fn ( ) , // set up a mock function for useDispatch
47
- } ) ) ;
70
+ } ) ;
0 commit comments