diff --git a/src/Body/index.tsx b/src/Body/index.tsx index e10170e5a..96cf62994 100644 --- a/src/Body/index.tsx +++ b/src/Body/index.tsx @@ -110,6 +110,7 @@ function Body({ }, [ data, prefixCls, + onRow, measureColumnWidth, stickyOffsets, expandedKeys, diff --git a/tests/Table.spec.js b/tests/Table.spec.js index 57977ea0a..1f9335aa2 100644 --- a/tests/Table.spec.js +++ b/tests/Table.spec.js @@ -458,16 +458,47 @@ describe('Table.Basic', () => { expect(wrapper.find('tbody tr').length).toBeTruthy(); }); - it('renders onRow correctly', () => { - const onRow = (record, index) => ({ - id: `row-${record.key}`, - index, + describe('onRow', () => { + it('renders onRow correctly', () => { + const onRow = (record, index) => ({ + id: `row-${record.key}`, + index, + }); + const wrapper = mount(createTable({ onRow })); + + expect(wrapper.find('tbody tr').length).toBeTruthy(); + wrapper.find('tbody tr').forEach((tr, index) => { + expect(tr.props().id).toEqual(`row-${data[index].key}`); + }); }); - const wrapper = mount(createTable({ onRow })); - expect(wrapper.find('tbody tr').length).toBeTruthy(); - wrapper.find('tbody tr').forEach((tr, index) => { - expect(tr.props().id).toEqual(`row-${data[index].key}`); + it('onRow should keep update', () => { + const Test = () => { + const [count, setCount] = React.useState(0); + + return ( +
+ ({ + onClick() { + setCount(count + 1); + }, + })} + /> + {count} + + ); + }; + const wrapper = mount(); + for (let i = 0; i < 10; i += 1) { + wrapper + .find('tbody tr td') + .last() + .simulate('click'); + expect(wrapper.find('#count').text()).toEqual(String(i + 1)); + } }); });