From 10de86bf711e54424421f8dd29765aa399f9f9a8 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Tue, 30 Mar 2021 17:15:39 +0800 Subject: [PATCH] test: add more test & up doc --- README.md | 1 + tests/ExpandRow.spec.js | 60 ++++ tests/__snapshots__/ExpandRow.spec.js.snap | 307 +++++++++++++++++++++ 3 files changed, 368 insertions(+) diff --git a/README.md b/README.md index 661a4f43b..b6556d9cb 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ React.render(, mountNode); | expandable.rowExpandable | (record) => boolean | | Config row support expandable | | expandable.onExpand | Function(expanded, record) | | function to call when click expand icon | | expandable.onExpandedRowsChange | Function(expandedRows) | | function to call when the expanded rows change | +| expandable.fixed | String \| Boolean | - | this expand icon will be fixed when table scroll horizontally: true or `left` or `right` and `expandIconColumnIndex` need to stay first or last | | rowKey | string or Function(record):string | 'key' | If rowKey is string, `record[rowKey]` will be used as key. If rowKey is function, the return value of `rowKey(record)` will be use as key. | | rowClassName | string or Function(record, index, indent):string | | get row's className | | rowRef | Function(record, index, indent):string | | get row's ref key | diff --git a/tests/ExpandRow.spec.js b/tests/ExpandRow.spec.js index 70e60c0b2..d08b686ea 100644 --- a/tests/ExpandRow.spec.js +++ b/tests/ExpandRow.spec.js @@ -140,6 +140,66 @@ describe('Table.Expand', () => { }); }); + it('work in expandable fix', () => { + const columns = [ + { title: 'Name', dataIndex: 'name', key: 'name' }, + { title: 'Age', dataIndex: 'age', key: 'age' }, + { title: 'Gender', dataIndex: 'gender', key: 'gender' }, + ]; + const data = [ + { key: 0, name: 'Lucy', age: 27, gender: 'F' }, + { key: 1, name: 'Jack', age: 28, gender: 'M' }, + ]; + const wrapper = mount( + createTable({ + columns, + data, + scroll: { x: 903 }, + expandable: { expandedRowRender, fixed: true }, + }), + ); + const wrapper2 = mount( + createTable({ + columns, + data, + scroll: { x: 903 }, + expandable: { expandedRowRender, fixed: true, expandIconColumnIndex: 3 }, + }), + ); + expect(wrapper.render()).toMatchSnapshot(); + expect(wrapper2.render()).toMatchSnapshot(); + }); + + it('expandable fix not when expandIconColumnIndex', () => { + const columns = [ + { title: 'Name', dataIndex: 'name', key: 'name' }, + { title: 'Age', dataIndex: 'age', key: 'age' }, + { title: 'Gender', dataIndex: 'gender', key: 'gender' }, + ]; + const data = [ + { key: 0, name: 'Lucy', age: 27, gender: 'F' }, + { key: 1, name: 'Jack', age: 28, gender: 'M' }, + ]; + const wrapper = mount( + createTable({ + columns, + data, + scroll: { x: 903 }, + expandable: { expandedRowRender, fixed: 'left', expandIconColumnIndex: 1 }, + }), + ); + const wrapper2 = mount( + createTable({ + columns, + data, + scroll: { x: 903 }, + expandable: { expandedRowRender, fixed: 'right', expandIconColumnIndex: 2 }, + }), + ); + expect(wrapper.find('.rc-table-has-fix-left').length).toBe(0); + expect(wrapper2.find('.rc-table-has-fix-right').length).toBe(0); + }); + it('renders expand icon to the specify column', () => { const wrapper = mount( createTable({ diff --git a/tests/__snapshots__/ExpandRow.spec.js.snap b/tests/__snapshots__/ExpandRow.spec.js.snap index b274b4523..ff95da721 100644 --- a/tests/__snapshots__/ExpandRow.spec.js.snap +++ b/tests/__snapshots__/ExpandRow.spec.js.snap @@ -648,3 +648,310 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = ` `; + +exports[`Table.Expand work in expandable fix 1`] = ` +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Name + + Age + + Gender +
+ + + Lucy + + 27 + + F +
+ + + Jack + + 28 + + M +
+ + + +`; + +exports[`Table.Expand work in expandable fix 2`] = ` +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Name + + Age + + Gender + +
+ Lucy + + 27 + + F + + +
+ Jack + + 28 + + M + + +
+
+
+
+`;