@@ -5,11 +5,13 @@ import { Provider } from 'react-redux';
5
5
import { configureStore } from '@reduxjs/toolkit' ;
6
6
import { mainSlice } from '../RTKslices'
7
7
import { useDispatch } from 'react-redux' ;
8
+ import { ThemeProvider } from '@mui/material/styles' ;
9
+ import theme from '../components/theme' ;
8
10
import '@testing-library/jest-dom/extend-expect' ; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
9
11
10
12
const customTabs = {
11
13
87 : {
12
- snapshots : [ 1 , 2 , 3 , 4 ] ,
14
+ snapshots : [ 0 , 1 , 2 , 3 ] ,
13
15
hierarchy : {
14
16
index : 0 ,
15
17
name : 1 ,
@@ -100,6 +102,7 @@ const customTabs = {
100
102
} ,
101
103
sliderIndex : 3 , //updated to 3
102
104
viewIndex : - 1 ,
105
+ playing : false ,
103
106
} ,
104
107
}
105
108
@@ -124,11 +127,15 @@ const customStore = configureStore({
124
127
getDefaultMiddleware ( { serializableCheck : false } ) ,
125
128
} ) ;
126
129
127
- const render = component => rtlRender (
130
+ const renderWithTheme = ( component ) => {
131
+ return rtlRender (
128
132
< Provider store = { customStore } >
129
- { component }
133
+ < ThemeProvider theme = { theme } >
134
+ { component }
135
+ </ ThemeProvider >
130
136
</ Provider >
131
- ) ;
137
+ ) ;
138
+ } ;
132
139
133
140
const mockSlider = jest . fn ( ) ;
134
141
jest . mock ( '../components/MainSlider' , ( ) => ( props ) => {
@@ -149,7 +156,7 @@ jest.mock('react-redux', () => ({
149
156
150
157
describe ( 'All elements appear in the TravelContainer module' , ( ) => {
151
158
beforeEach ( ( ) => {
152
- render ( < TravelContainer snapshotsLength = { 0 } /> ) ;
159
+ renderWithTheme ( < TravelContainer snapshotsLength = { 0 } /> ) ;
153
160
} ) ;
154
161
155
162
test ( 'first button contains text Play' , ( ) => {
@@ -166,19 +173,19 @@ describe('All elements appear in the TravelContainer module', () => {
166
173
} ) ;
167
174
168
175
test ( 'Backward button exists in document' , ( ) => {
169
- let buttons = screen . getAllByRole ( 'button' ) ;
170
- expect ( buttons [ 1 ] ) . toHaveTextContent ( '<' ) ;
171
- } ) ;
176
+ // Use the getByLabelText query to find the button by its label
177
+ const backwardButton = screen . getByLabelText ( 'Backward' ) ;
178
+ expect ( backwardButton ) . toBeInTheDocument ( ) ;
179
+ } ) ;
172
180
173
- test ( 'Forward button exists in document' , ( ) => {
174
- let buttons = screen . getAllByRole ( 'button ') ;
175
- expect ( buttons [ 2 ] ) . toHaveTextContent ( '>' ) ;
176
- } ) ;
181
+ test ( 'Forward button exists in document' , ( ) => {
182
+ const forwardButton = screen . getByLabelText ( 'Forward ') ;
183
+ expect ( forwardButton ) . toBeInTheDocument ( ) ;
184
+ } ) ;
177
185
} ) ;
178
-
186
+
179
187
// describe('Testing backward and forward button', () => {
180
188
// beforeEach(() => {
181
- // dispatch.mockClear();
182
189
// render(<TravelContainer snapshotsLength={0} />);
183
190
// });
184
191
0 commit comments