2016-03-05 21:06:04 -08:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-05-13 20:04:56 -07:00
|
|
|
import classnames from 'classnames';
|
2016-03-05 21:06:04 -08:00
|
|
|
import PureComponent from 'react-pure-render/component';
|
|
|
|
import { Col, Row } from 'react-bootstrap';
|
|
|
|
|
|
|
|
export default class extends PureComponent {
|
|
|
|
static displayName = 'TestSuite';
|
2016-09-02 22:09:21 -07:00
|
|
|
static propTypes = {
|
2016-05-27 22:21:52 -07:00
|
|
|
tests: PropTypes.arrayOf(PropTypes.object)
|
2016-03-05 21:06:04 -08:00
|
|
|
};
|
|
|
|
|
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 (
|
|
|
|
<Row key={ text.slice(-6) + index }>
|
|
|
|
<Col
|
|
|
|
className='text-center'
|
2016-06-14 18:47:43 -07:00
|
|
|
xs={ 2 }
|
|
|
|
>
|
2016-03-05 21:06:04 -08:00
|
|
|
<i className={ iconClass } />
|
|
|
|
</Col>
|
|
|
|
<Col
|
|
|
|
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
|
|
|
|
className='challenge-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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|