Files
freeCodeCamp/common/app/routes/challenges/components/Test-Suite.jsx
Berkeley Martinez f1d936198e feat(challenges): add backend challenge infrastructure (#11058)
* Feat: Initial backend view

* Feat: Refactor frame runner

* Feat: backend challenge submit runs tests

* Feat: Backend challenge request

* Feat: Whitelist hyperdev in csp

* Fix: Use app tests instead of challenge tests

* Feat: Allow hyperdev subdomains

* Fix(csp): allow hypderdev.space subdomains

* feat(challenge): submit backend

* feat: Add timeout to test runner (5 sec)

* chore(seed): Add more to test backend

* fix(csp): s/hyperdev/gomix/g

* fix(app): fix code mirror skeleton filepath

* fix(app): remove Gitter saga import

* fix(app): codemirrorskeleton does not need it's own folder
fix(app): cmk needs to work with Null types

* fix: No longer restart the browser when challenges change

* fix(app): Update jquery for challenges

* fix(seed): Remove to promise jquery call

* fix(lint): Undo merge error
undefined is no allowed

* fix(app): linting errors due to bad merge

* fix(seed): Remove old seed file
2017-01-26 23:07:22 -06:00

56 lines
1.4 KiB
JavaScript

import React, { PropTypes, PureComponent } from 'react';
import classnames from 'classnames';
import { Col, Row } from 'react-bootstrap';
const propTypes = {
tests: PropTypes.arrayOf(PropTypes.object)
};
export default class TestSuite extends PureComponent {
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)=> {
const iconClass = classnames({
'big-icon': true,
'ion-close-circled error-icon': err && !pass,
'ion-checkmark-circled success-icon': !err && pass,
'ion-refresh refresh-icon': !err && !pass
});
return (
<Row key={ text.slice(-6) + index }>
<Col
className='text-center'
xs={ 2 }
>
<i className={ iconClass } />
</Col>
<Col
className='test-output'
dangerouslySetInnerHTML={{ __html: text }}
xs={ 10 }
/>
</Row>
);
});
}
render() {
const { tests } = this.props;
return (
<div
className='challenge-test-suite'
style={{ marginTop: '10px' }}
>
{ this.renderTests(tests) }
<div className='big-spacer' />
</div>
);
}
}
TestSuite.displayName = 'TestSuite';
TestSuite.propTypes = propTypes;