Skip to content

Commit

Permalink
Block Editor: ContrastChecker: Add test case to verify re-announce on…
Browse files Browse the repository at this point in the history
… color change
  • Loading branch information
aduth committed Feb 4, 2020
1 parent 737bfef commit 8ce0dae
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* External dependencies
*/
import { mount } from 'enzyme';
import { render } from 'react-dom';
import { act } from 'react-dom/test-utils';

/**
* WordPress dependencies
Expand Down Expand Up @@ -260,4 +262,30 @@ describe( 'ContrastChecker', () => {
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
);
} );

test( 'should re-announce if colors change, but still insufficient contrast', () => {
const appRoot = document.createElement( 'div' );

act( () => {
render(
<ContrastChecker
textColor={ textColor }
fallbackBackgroundColor={ textColor }
/>,
appRoot
);
} );

act( () => {
render(
<ContrastChecker
textColor={ backgroundColor }
fallbackBackgroundColor={ backgroundColor }
/>,
appRoot
);
} );

expect( speak ).toHaveBeenCalledTimes( 2 );
} );
} );

0 comments on commit 8ce0dae

Please sign in to comment.