Add an end-to-end component test for App
Summary: This should ensure that there aren’t any runtime PropTypes errors. The change to reimplement `Object.entries` is due to the fact that my local Node environment (v6.11.1) does not yet support that ESnext function. Test Plan: Apply the following diff (`git apply`): ```diff diff --git a/explorer/src/UserExplorer.js b/explorer/src/UserExplorer.js index 8da252d..cdc1370 100644 --- a/explorer/src/UserExplorer.js +++ b/explorer/src/UserExplorer.js @@ -10,7 +10,7 @@ export class UserExplorer extends Component { static propTypes = { selectedPath: PropTypes.string.isRequired, selectedUser: PropTypes.string, - onSelectUser: PropTypes.func.isRequired, + onSelectUser: PropTypes.number.isRequired, data: commitUtilsPropTypes.commitData.isRequired, } ``` Then, `yarn test` should fail. Revert the diff, and `yarn test` should pass. wchargin-branch: react-proptypes-test
This commit is contained in:
parent
1d0368411c
commit
c1b37fa729
|
@ -0,0 +1,10 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
// Check that PropTypes check out.
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(<App />, div);
|
||||
ReactDOM.unmountComponentAtNode(div);
|
||||
});
|
|
@ -16,7 +16,10 @@ export class UserExplorer extends Component {
|
|||
|
||||
render() {
|
||||
const weights = userWeightForPath(this.props.selectedPath, this.props.data, commitWeight);
|
||||
const sortedUserWeightTuples = Object.entries(weights).sort((a,b) => b[1] - a[1]);
|
||||
const sortedUserWeightTuples =
|
||||
Object.keys(weights)
|
||||
.map(k => [k, weights[k]])
|
||||
.sort((a,b) => b[1] - a[1]);
|
||||
const entries = sortedUserWeightTuples.map(authorWeight => {
|
||||
const [author, weight] = authorWeight;
|
||||
return <UserEntry userId={author} weight={weight} key={author}/>
|
||||
|
|
Loading…
Reference in New Issue