Update tests to use pass/err to determine refresh
This commit is contained in:
@ -15,21 +15,18 @@ const mapStateToProps = createSelector(
|
|||||||
state => state.app.windowHeight,
|
state => state.app.windowHeight,
|
||||||
state => state.app.navHeight,
|
state => state.app.navHeight,
|
||||||
state => state.challengesApp.tests,
|
state => state.challengesApp.tests,
|
||||||
state => state.challengesApp.refresh,
|
|
||||||
state => state.challengesApp.output,
|
state => state.challengesApp.output,
|
||||||
(
|
(
|
||||||
{ challenge: { title, description } = {} },
|
{ challenge: { title, description } = {} },
|
||||||
windowHeight,
|
windowHeight,
|
||||||
navHeight,
|
navHeight,
|
||||||
tests,
|
tests,
|
||||||
refresh,
|
|
||||||
output
|
output
|
||||||
) => ({
|
) => ({
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
height: windowHeight - navHeight - 20,
|
height: windowHeight - navHeight - 20,
|
||||||
tests,
|
tests,
|
||||||
refresh,
|
|
||||||
output
|
output
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -46,7 +43,6 @@ export class SidePanel extends PureComponent {
|
|||||||
height: PropTypes.number,
|
height: PropTypes.number,
|
||||||
tests: PropTypes.arrayOf(PropTypes.object),
|
tests: PropTypes.arrayOf(PropTypes.object),
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
refresh: PropTypes.bool,
|
|
||||||
output: PropTypes.string
|
output: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,7 +70,6 @@ export class SidePanel extends PureComponent {
|
|||||||
description,
|
description,
|
||||||
height,
|
height,
|
||||||
tests = [],
|
tests = [],
|
||||||
refresh,
|
|
||||||
output
|
output
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const style = {
|
const style = {
|
||||||
@ -104,9 +99,7 @@ export class SidePanel extends PureComponent {
|
|||||||
<ToolPanel />
|
<ToolPanel />
|
||||||
<Output output={ output }/>
|
<Output output={ output }/>
|
||||||
<br />
|
<br />
|
||||||
<TestSuite
|
<TestSuite tests={ tests } />
|
||||||
refresh={ refresh }
|
|
||||||
tests={ tests } />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,20 @@ import { Col, Row } from 'react-bootstrap';
|
|||||||
export default class extends PureComponent {
|
export default class extends PureComponent {
|
||||||
static displayName = 'TestSuite';
|
static displayName = 'TestSuite';
|
||||||
static proptTypes = {
|
static proptTypes = {
|
||||||
tests: PropTypes.arrayOf(PropTypes.object),
|
tests: PropTypes.arrayOf(PropTypes.object)
|
||||||
refresh: PropTypes.bool
|
|
||||||
};
|
};
|
||||||
|
|
||||||
renderTests(tests = [], refresh = false) {
|
renderTests(tests = []) {
|
||||||
return tests.map(({ err, text = '' }, index)=> {
|
// 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({
|
const iconClass = classnames({
|
||||||
'big-icon': true,
|
'big-icon': true,
|
||||||
'ion-close-circled error-icon': !refresh && err,
|
'ion-close-circled error-icon': err && !pass,
|
||||||
'ion-checkmark-circled success-icon': !refresh && !err,
|
'ion-checkmark-circled success-icon': !err && pass,
|
||||||
'ion-refresh refresh-icon': refresh
|
'ion-refresh refresh-icon': !err && !pass
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<Row key={ text.slice(-6) + index }>
|
<Row key={ text.slice(-6) + index }>
|
||||||
@ -35,12 +38,12 @@ export default class extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { tests, refresh } = this.props;
|
const { tests } = this.props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className='challenge-test-suite'
|
className='challenge-test-suite'
|
||||||
style={{ marginTop: '10px' }}>
|
style={{ marginTop: '10px' }}>
|
||||||
{ this.renderTests(tests, refresh) }
|
{ this.renderTests(tests) }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ const mainReducer = handleActions(
|
|||||||
}),
|
}),
|
||||||
[types.updateCurrentChallenge]: (state, { payload: challenge }) => ({
|
[types.updateCurrentChallenge]: (state, { payload: challenge }) => ({
|
||||||
...state,
|
...state,
|
||||||
refresh: true,
|
|
||||||
id: challenge.id,
|
id: challenge.id,
|
||||||
// used mainly to find code storage
|
// used mainly to find code storage
|
||||||
legacyKey: challenge.name,
|
legacyKey: challenge.name,
|
||||||
@ -40,10 +39,12 @@ const mainReducer = handleActions(
|
|||||||
}),
|
}),
|
||||||
[types.updateTests]: (state, { payload: tests }) => ({
|
[types.updateTests]: (state, { payload: tests }) => ({
|
||||||
...state,
|
...state,
|
||||||
refresh: false,
|
|
||||||
tests
|
tests
|
||||||
}),
|
}),
|
||||||
[types.executeChallenge]: state => ({ ...state, refresh: true }),
|
[types.executeChallenge]: state => ({
|
||||||
|
...state,
|
||||||
|
tests: state.tests.map(test => ({ ...test, err: false, pass: false }))
|
||||||
|
}),
|
||||||
|
|
||||||
// map
|
// map
|
||||||
[types.updateFilter]: (state, { payload = ''}) => ({
|
[types.updateFilter]: (state, { payload = ''}) => ({
|
||||||
|
Reference in New Issue
Block a user