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';
|
|
|
|
static proptTypes = {
|
2016-05-13 20:04:56 -07:00
|
|
|
tests: PropTypes.arrayOf(PropTypes.object),
|
|
|
|
refresh: PropTypes.bool
|
2016-03-05 21:06:04 -08:00
|
|
|
};
|
|
|
|
|
2016-05-13 20:04:56 -07:00
|
|
|
renderTests(tests = [], refresh = false) {
|
2016-03-05 21:06:04 -08:00
|
|
|
return tests.map(({ err, text = '' }, index)=> {
|
2016-05-13 20:04:56 -07:00
|
|
|
const iconClass = classnames({
|
|
|
|
'big-icon': true,
|
2016-05-25 18:28:20 -07:00
|
|
|
'ion-close-circled error-icon': !refresh && err,
|
|
|
|
'ion-checkmark-circled success-icon': !refresh && !err,
|
2016-05-13 20:04:56 -07:00
|
|
|
'ion-refresh refresh-icon': refresh
|
|
|
|
});
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
|
|
|
<Row key={ text.slice(-6) + index }>
|
|
|
|
<Col
|
|
|
|
className='text-center'
|
|
|
|
xs={ 2 }>
|
|
|
|
<i className={ iconClass } />
|
|
|
|
</Col>
|
|
|
|
<Col
|
|
|
|
className='test-output'
|
2016-05-13 20:04:56 -07:00
|
|
|
dangerouslySetInnerHTML={{ __html: text }}
|
2016-03-05 21:06:04 -08:00
|
|
|
xs={ 10 } />
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-05-13 20:04:56 -07:00
|
|
|
const { tests, refresh } = this.props;
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className='challenge-test-suite'
|
|
|
|
style={{ marginTop: '10px' }}>
|
2016-05-13 20:04:56 -07:00
|
|
|
{ this.renderTests(tests, refresh) }
|
2016-03-05 21:06:04 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|