File tree Expand file tree Collapse file tree 2 files changed +11
-29
lines changed
Expand file tree Collapse file tree 2 files changed +11
-29
lines changed Original file line number Diff line number Diff line change @@ -17,16 +17,16 @@ const Component = ({
1717 initialVisibility = { initialVisibility }
1818 imagesDisplayed = { imagesDisplayed }
1919 >
20- < img src = "1" />
21- < img src = "2" />
22- < img src = "3" />
23- < img src = "4" />
24- < img src = "5" />
25- < img src = "6" />
26- < img src = "7" />
27- < img src = "8" />
28- < img src = "9" />
29- < img src = "10" />
20+ < img src = "1" alt = "0" />
21+ < img src = "2" alt = "1" />
22+ < img src = "3" alt = "2" />
23+ < img src = "4" alt = "3" />
24+ < img src = "5" alt = "4" />
25+ < img src = "6" alt = "5" />
26+ < img src = "7" alt = "6" />
27+ < img src = "8" alt = "7" />
28+ < img src = "9" alt = "8" />
29+ < img src = "10" alt = "9" />
3030 </ Gallery >
3131) ;
3232
@@ -74,14 +74,6 @@ describe('<Gallery /> rendering', () => {
7474 ) ;
7575 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
7676 } ) ;
77-
78- it ( 'should return console error when item is invalid children' , ( ) => {
79- const error = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
80- render ( < GalleryItemWithInvalidChildren /> ) ;
81-
82- expect ( error ) . toBeCalledWith ( 'Only img components allowed as children.' ) ;
83- error . mockRestore ( ) ;
84- } ) ;
8577} ) ;
8678
8779describe ( '<Gallery /> open and close Slider modal' , ( ) => {
Original file line number Diff line number Diff line change @@ -35,13 +35,6 @@ const Gallery = ({
3535
3636 const getCurrentIndex = ( index : number ) => setCurrentIndex ( index - 1 ) ;
3737
38- const hasImage = React . Children . toArray ( children ) . some ( child => {
39- return React . isValidElement ( child ) && child . type === 'img' ;
40- } ) ;
41- if ( ! hasImage ) {
42- console . error ( 'Only img components allowed as children.' ) ;
43- }
44-
4538 React . useEffect ( function componentDidMount ( ) {
4639 if ( React . Children . count ( children ) > imagesDisplayed )
4740 setImageLeft ( React . Children . count ( children ) - imagesDisplayed ) ;
@@ -93,9 +86,7 @@ const Gallery = ({
9386 ( data : React . ReactElement < React . HTMLProps < 'img' > > , index ) => (
9487 < Slider . Item key = { `${ data . props . src } _${ index } ` } >
9588 < GalleryImageWrapper role = "banner" tabIndex = { 0 } >
96- { React . cloneElement ( data , {
97- alt : index . toString ( 10 ) ,
98- } ) }
89+ { data }
9990 </ GalleryImageWrapper >
10091 </ Slider . Item >
10192 )
@@ -117,7 +108,6 @@ const Gallery = ({
117108 { React . cloneElement ( data , {
118109 className : index === currentIndex ? 'active' : null ,
119110 'data-testid' : 'gallery_thumbnail' ,
120- alt : index . toString ( 10 ) ,
121111 } ) }
122112 </ div >
123113 )
You can’t perform that action at this time.
0 commit comments