File tree Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module.exports = {
31
31
'react/prop-types' : 'off' ,
32
32
'react/no-unknown-property' : 'off' ,
33
33
'react/react-in-jsx-scope' : 'off' ,
34
+ '@next/next/no-img-element' : 'off' ,
34
35
35
36
// many of these rules are taken from our friends at Creative Labs;
36
37
// see their config here: https://github.com/UCLA-Creative-Labs/sunshine/blob/master/.eslintrc.js
Original file line number Diff line number Diff line change
1
+ import { render } from '@testing-library/react' ;
2
+ import { axe , toHaveNoViolations } from 'jest-axe' ;
3
+ import React from 'react' ;
4
+ import { act } from 'react-dom/test-utils' ;
5
+ import Officers from '../../components/LeadershipOfficers' ;
6
+ import data from '../../data' ;
7
+
8
+ expect . extend ( toHaveNoViolations ) ;
9
+
10
+ // TODO: consider lifting this mock globally
11
+ jest . mock ( 'next/image' , ( ) => ( {
12
+ __esModule : true ,
13
+ default : ( props ) => {
14
+ // eslint-disable-next-line @next/next/no-img-element
15
+ return < img alt = { props . alt } { ...props } /> ;
16
+ } ,
17
+ } ) ) ;
18
+
19
+ it ( 'has no axe violations' , async ( ) => {
20
+ const { leadership } = data ;
21
+
22
+ // this let / async construct is required since next/image rendering
23
+ // is a side effect that needs to be captured with async act
24
+ // see https://reactjs.org/docs/test-utils.html#act
25
+ let results ;
26
+ await act ( async ( ) => {
27
+ const { container } = render ( < Officers officers = { leadership } /> ) ;
28
+ results = await axe ( container ) ;
29
+ } ) ;
30
+
31
+ expect ( results ) . toHaveNoViolations ( ) ;
32
+ } ) ;
Original file line number Diff line number Diff line change @@ -23,11 +23,13 @@ function Officer(props) {
23
23
function Officers ( props ) {
24
24
return (
25
25
// TODO: more flexible mobile views
26
- ( < div className = "grid-desktop-3" >
27
- { props . officers . map ( ( officer ) => (
28
- < Officer officer = { officer } key = { officer . image } />
29
- ) ) }
30
- </ div > )
26
+ < div className = "grid-desktop-3" >
27
+ {
28
+ props . officers . map (
29
+ officer => < Officer officer = { officer } key = { officer . name + officer . position } /> ,
30
+ )
31
+ }
32
+ </ div >
31
33
) ;
32
34
}
33
35
You can’t perform that action at this time.
0 commit comments