@@ -13,11 +13,10 @@ const customTabs = {
1313 } ,
1414 }
1515
16-
1716const customInitialState = {
1817 main : {
1918 port : null ,
20- currentTab : 87 ,
19+ currentTab : 100 ,
2120 currentTitle : null ,
2221 tabs : customTabs , // Replace with the actual (testing) tab data
2322 currentTabInApp : null ,
@@ -39,9 +38,33 @@ const render = component => rtlRender(
3938 < Provider store = { customStore } >
4039 { component }
4140 </ 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+ } ) ;
4369
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