Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent wallet page crash - Closes #3477 #3480

Merged
merged 2 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/toolbox/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import styles from './table.css';
* you can use this property.
*/
const Table = ({
data,
data = [],
UsamaHameed marked this conversation as resolved.
Show resolved Hide resolved
loadData,
header,
row,
Expand Down
7 changes: 7 additions & 0 deletions src/components/toolbox/table/table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ describe('Table', () => {
const wrapper = mount(<Table {...props} />);
expect(wrapper.find('Row')).toHaveLength(props.data.length);
});

it('should render accept function to define iteration key', () => {
const iterationKey = jest.fn().mockImplementation(data => data.address);
mount(<Table {...props} iterationKey={iterationKey} />);
expect(iterationKey.mock.calls.length).toBe(props.data.length);
});

it('should not crash when data is undefined', () => {
const wrapper = mount(<Table {...props} data={undefined} />);
expect(wrapper.find('.empty-state')).toHaveLength(1);
expect(wrapper.find('Row')).toHaveLength(0);
});
});
});
2 changes: 1 addition & 1 deletion src/store/reducers/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const voting = (state = {}, action) => {
switch (action.type) {
case actionTypes.votesRetrieved: {
if (action.data.account.votesUsed) {
return action.data
return action.data.votes
.reduce((votesDict, delegate) => {
votesDict[delegate.address] = {
confirmed: Number(delegate.amount),
Expand Down