Merge pull request #15758 from xnt/fix/testResults-a11y

fix(challenges): Provide accessible test description and status
pull/15846/merge
Berkeley Martinez 2017-09-04 14:22:05 -07:00 committed by GitHub
commit 3be6775245
1 changed files with 24 additions and 2 deletions

View File

@ -8,6 +8,20 @@ const propTypes = {
tests: PropTypes.arrayOf(PropTypes.object)
};
function getAccessibleText(err, pass, text) {
let accessibleText = 'Waiting';
// Determine test status (i.e. icon)
if (err) {
accessibleText = 'Error';
} else if (pass) {
accessibleText = 'Pass';
}
// Append the text itself
return accessibleText + ' - ' + text;
}
export default class TestSuite extends PureComponent {
renderTests(tests = []) {
// err && pass > invalid state
@ -22,14 +36,22 @@ export default class TestSuite extends PureComponent {
'ion-refresh refresh-icon': !err && !pass
});
return (
<Row key={ text.slice(-6) + index }>
<Row
aria-label={ getAccessibleText(err, pass, text) }
key={ text.slice(-6) + index }
tabIndex='0'
>
<Col
className='text-center'
xs={ 2 }
>
<i className={ iconClass } />
<i
aria-hidden='true'
className={ iconClass }
/>
</Col>
<Col
aria-hidden='true'
className='test-output'
dangerouslySetInnerHTML={{ __html: text }}
xs={ 10 }