should recieve newest selectRow.selected

This commit is contained in:
AllenFang
2018-03-18 14:07:44 +08:00
parent 923439dc81
commit 55336108a0
2 changed files with 12 additions and 3 deletions

View File

@@ -30,8 +30,9 @@ export default Base =>
}
componentWillReceiveProps(nextProps) {
nextProps.store.selected = nextProps.selectRow.selected || [];
this.setState(() => ({
selectedRowKeys: nextProps.store.selected
selectedRowKeys: nextProps.selectRow.selected
}));
}

View File

@@ -70,11 +70,19 @@ describe('RowSelectionWrapper', () => {
describe('componentWillReceiveProps', () => {
const nextSelected = [0];
const nextProps = { store: { selected: nextSelected } };
const nextProps = {
store: {
selected: nextSelected
},
selectRow: {
mode: 'checkbox',
selected: nextSelected
}
};
it('should update state.selectedRowKeys with next selected rows', () => {
wrapper.instance().componentWillReceiveProps(nextProps);
expect(nextProps.store.selected).toEqual(nextSelected);
expect(wrapper.state('selectedRowKeys')).toEqual(nextSelected);
});
});