2017-11-09 17:10:30 -08:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-05-13 20:04:56 -07:00
|
|
|
import classnames from 'classnames';
|
2016-03-05 21:06:04 -08:00
|
|
|
import { Col, Row } from 'react-bootstrap';
|
|
|
|
|
2017-03-13 16:17:07 -07:00
|
|
|
import ns from './ns.json';
|
|
|
|
|
2017-01-26 21:07:22 -08:00
|
|
|
const propTypes = {
|
|
|
|
tests: PropTypes.arrayOf(PropTypes.object)
|
|
|
|
};
|
2016-03-05 21:06:04 -08:00
|
|
|
|
2017-08-12 14:02:09 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-01-26 21:07:22 -08:00
|
|
|
export default class TestSuite extends PureComponent {
|
2016-05-27 22:21:52 -07:00
|
|
|
renderTests(tests = []) {
|
|
|
|
// err && pass > invalid state
|
|
|
|
// err && !pass > failed tests
|
|
|
|
// !err && pass > passed tests
|
|
|
|
// !err && !pass > in-progress
|
|
|
|
return tests.map(({ err, pass = false, text = '' }, index)=> {
|
2016-05-13 20:04:56 -07:00
|
|
|
const iconClass = classnames({
|
|
|
|
'big-icon': true,
|
2016-05-27 22:21:52 -07:00
|
|
|
'ion-close-circled error-icon': err && !pass,
|
|
|
|
'ion-checkmark-circled success-icon': !err && pass,
|
|
|
|
'ion-refresh refresh-icon': !err && !pass
|
2016-05-13 20:04:56 -07:00
|
|
|
});
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
2017-08-12 14:02:09 -07:00
|
|
|
<Row
|
|
|
|
aria-label={ getAccessibleText(err, pass, text) }
|
|
|
|
key={ text.slice(-6) + index }
|
|
|
|
tabIndex='0'
|
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
<Col
|
|
|
|
className='text-center'
|
2016-06-14 18:47:43 -07:00
|
|
|
xs={ 2 }
|
|
|
|
>
|
2017-08-12 14:02:09 -07:00
|
|
|
<i
|
|
|
|
aria-hidden='true'
|
|
|
|
className={ iconClass }
|
|
|
|
/>
|
2016-03-05 21:06:04 -08:00
|
|
|
</Col>
|
|
|
|
<Col
|
2017-08-12 14:02:09 -07:00
|
|
|
aria-hidden='true'
|
2016-03-05 21:06:04 -08:00
|
|
|
className='test-output'
|
2016-05-13 20:04:56 -07:00
|
|
|
dangerouslySetInnerHTML={{ __html: text }}
|
2016-06-14 18:47:43 -07:00
|
|
|
xs={ 10 }
|
|
|
|
/>
|
2016-03-05 21:06:04 -08:00
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-05-27 22:21:52 -07:00
|
|
|
const { tests } = this.props;
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
|
|
|
<div
|
2017-03-13 16:17:07 -07:00
|
|
|
className={ `${ns}-test-suite` }
|
2016-06-14 18:47:43 -07:00
|
|
|
style={{ marginTop: '10px' }}
|
|
|
|
>
|
2016-05-27 22:21:52 -07:00
|
|
|
{ this.renderTests(tests) }
|
2016-06-27 19:23:30 -07:00
|
|
|
<div className='big-spacer' />
|
2016-03-05 21:06:04 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 21:07:22 -08:00
|
|
|
|
|
|
|
TestSuite.displayName = 'TestSuite';
|
|
|
|
TestSuite.propTypes = propTypes;
|