diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..71f4cc89f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +.doc +.storybook +es +lib \ No newline at end of file diff --git a/HISTORY.md b/HISTORY.md index 5936bd0b2..cac45f0f9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,6 @@ # History ----- + +--- ## 6.9.0 / 2019-10-18 @@ -104,7 +105,7 @@ Fix https://github.com/ant-design/ant-design/issues/2625 ## 4.4.1 / 2016-07-24 -- Fix row expand of key 0 record. (ant-design/ant-design#2471) +- Fix row expand of key 0 record. (ant-design/ant-design#2471) ## 4.4.0 / 2016-07-19 diff --git a/LICENSE.md b/LICENSE.md index 12189b627..69e806d2c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,21 +2,8 @@ MIT LICENSE Copyright (c) 2015-present Alipay.com, https://www.alipay.com/ -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 47e0f6ae3..dfd3dafb7 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,7 @@ React table component with useful functions. -[![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] -[![Test coverage][codecov-image]][codecov-url] -[![Dependencies][david-image]][david-url] -[![DevDependencies][david-dev-image]][david-dev-url] -[![npm download][download-image]][download-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] +[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [npm-image]: http://img.shields.io/npm/v/rc-table.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-table diff --git a/examples/react-dnd.tsx b/examples/react-dnd.tsx index 1baee6b7d..511dcbf3a 100644 --- a/examples/react-dnd.tsx +++ b/examples/react-dnd.tsx @@ -148,7 +148,10 @@ class Demo extends React.Component { this.setState(prevState => update(prevState, { data: { - $splice: [[dragIndex, 1], [hoverIndex, 0, dragRow]], + $splice: [ + [dragIndex, 1], + [hoverIndex, 0, dragRow], + ], }, }), ); diff --git a/examples/title-and-footer.tsx b/examples/title-and-footer.tsx index 2a100d054..25e929b14 100644 --- a/examples/title-and-footer.tsx +++ b/examples/title-and-footer.tsx @@ -63,20 +63,20 @@ const Demo = () => { title={currentData =>
Title: {currentData.length} items
} footer={currentData =>
Footer: {currentData.length} items
} summary={currentData => ( - <> - - Summary - - - - - - - - - {currentData.reduce((total, item) => total + item.value, 0)} - {currentData.reduce((total, item) => total + item.value2, 0)} - - - - - )} + <> + + Summary + + + - + - + - + {currentData.reduce((total, item) => total + item.value, 0)} + {currentData.reduce((total, item) => total + item.value2, 0)} + - + + + )} /> ); diff --git a/src/Header/HeaderRow.tsx b/src/Header/HeaderRow.tsx index 18de958dd..36de20617 100644 --- a/src/Header/HeaderRow.tsx +++ b/src/Header/HeaderRow.tsx @@ -34,7 +34,10 @@ function HeaderRow({ let rowProps: React.HTMLAttributes; if (onHeaderRow) { - rowProps = onHeaderRow(cells.map(cell => cell.column), index); + rowProps = onHeaderRow( + cells.map(cell => cell.column), + index, + ); } const columnsKey = getColumnsKey(cells.map(cell => cell.column)); diff --git a/src/interface.ts b/src/interface.ts index 93ad645c8..1bc93a82c 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -91,7 +91,8 @@ export interface ColumnType extends ColumnSharedType { export type ColumnsType = ( | ColumnGroupType - | ColumnType)[]; + | ColumnType +)[]; export type GetRowKey = (record: RecordType, index?: number) => Key; diff --git a/tests/ExpandRow.spec.js b/tests/ExpandRow.spec.js index 66e50a2c4..70e60c0b2 100644 --- a/tests/ExpandRow.spec.js +++ b/tests/ExpandRow.spec.js @@ -13,7 +13,10 @@ describe('Table.Expand', () => { { title: 'Age', dataIndex: 'age', key: 'age' }, ]; - const sampleData = [{ key: 0, name: 'Lucy', age: 27 }, { key: 1, name: 'Jack', age: 28 }]; + const sampleData = [ + { key: 0, name: 'Lucy', age: 27 }, + { key: 1, name: 'Jack', age: 28 }, + ]; const createTable = props => ; @@ -130,11 +133,7 @@ describe('Table.Expand', () => { }), ); act(() => { - wrapper - .find('ResizeObserver') - .first() - .props() - .onResize({ width: 1128 }); + wrapper.find('ResizeObserver').first().props().onResize({ width: 1128 }); }); wrapper.update(); expect(wrapper.render()).toMatchSnapshot(); @@ -151,10 +150,7 @@ describe('Table.Expand', () => { }), ); expect( - wrapper - .find('tbody tr td') - .at(1) - .hasClass('rc-table-row-expand-icon-cell'), + wrapper.find('tbody tr td').at(1).hasClass('rc-table-row-expand-icon-cell'), ).toBeTruthy(); }); @@ -212,12 +208,7 @@ describe('Table.Expand', () => { }), ); expect(wrapper.find('tbody tr')).toHaveLength(3); - expect( - wrapper - .find('tbody tr') - .at(2) - .hasClass('rc-table-expanded-row'), - ).toBeTruthy(); + expect(wrapper.find('tbody tr').at(2).hasClass('rc-table-expanded-row')).toBeTruthy(); }); it('controlled by expandedRowKeys', () => { @@ -228,33 +219,13 @@ describe('Table.Expand', () => { }), ); expect(wrapper.find('tbody tr')).toHaveLength(3); - expect( - wrapper - .find('tbody tr') - .at(1) - .hasClass('rc-table-expanded-row'), - ).toBeTruthy(); + expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy(); wrapper.setProps({ expandedRowKeys: [1] }); expect(wrapper.find('tbody tr')).toHaveLength(4); - expect( - wrapper - .find('tbody tr') - .at(1) - .hasClass('rc-table-expanded-row'), - ).toBeTruthy(); - expect( - wrapper - .find('tbody tr') - .at(1) - .props().style.display, - ).toEqual('none'); - expect( - wrapper - .find('tbody tr') - .at(3) - .hasClass('rc-table-expanded-row'), - ).toBeTruthy(); + expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy(); + expect(wrapper.find('tbody tr').at(1).props().style.display).toEqual('none'); + expect(wrapper.find('tbody tr').at(3).hasClass('rc-table-expanded-row')).toBeTruthy(); }); it('renders expend row class correctly', () => { @@ -269,12 +240,7 @@ describe('Table.Expand', () => { }), ); - expect( - wrapper - .find('tbody tr') - .at(1) - .hasClass('expand-row-test-class-name'), - ).toBeTruthy(); + expect(wrapper.find('tbody tr').at(1).hasClass('expand-row-test-class-name')).toBeTruthy(); }); it('fires expand change event', () => { @@ -287,16 +253,10 @@ describe('Table.Expand', () => { }, }), ); - wrapper - .find('.rc-table-row-expand-icon') - .first() - .simulate('click'); + wrapper.find('.rc-table-row-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]); - wrapper - .find('.rc-table-row-expand-icon') - .first() - .simulate('click'); + wrapper.find('.rc-table-row-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]); }); @@ -308,10 +268,7 @@ describe('Table.Expand', () => { onExpandedRowsChange, }), ); - wrapper - .find('.rc-table-row-expand-icon') - .first() - .simulate('click'); + wrapper.find('.rc-table-row-expand-icon').first().simulate('click'); expect(onExpandedRowsChange).toHaveBeenCalledWith([0]); }); @@ -339,16 +296,10 @@ describe('Table.Expand', () => { }, }), ); - wrapper - .find('tbody tr') - .first() - .simulate('click'); + wrapper.find('tbody tr').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]); - wrapper - .find('tbody tr') - .first() - .simulate('click'); + wrapper.find('tbody tr').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]); }); @@ -410,30 +361,14 @@ describe('Table.Expand', () => { }), ); expect(wrapper.find('.rc-table-expanded-row').length).toBe(0); - wrapper - .find('.custom-expand-icon') - .first() - .simulate('click'); + wrapper.find('.custom-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(true, data[0]); expect(onExpand).toHaveBeenCalledTimes(1); - expect( - wrapper - .find('.rc-table-expanded-row') - .first() - .getDOMNode().style.display, - ).toBe(''); - wrapper - .find('.custom-expand-icon') - .first() - .simulate('click'); + expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe(''); + wrapper.find('.custom-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(false, data[0]); expect(onExpand).toHaveBeenCalledTimes(2); - expect( - wrapper - .find('.rc-table-expanded-row') - .first() - .getDOMNode().style.display, - ).toBe('none'); + expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('none'); }); // https://github.com/ant-design/ant-design/issues/23894 @@ -450,16 +385,10 @@ describe('Table.Expand', () => { data, }), ); - wrapper - .find('.rc-table-row-expand-icon') - .first() - .simulate('click'); + wrapper.find('.rc-table-row-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(true, data[0]); expect(onExpand).toHaveBeenCalledTimes(1); - wrapper - .find('.rc-table-row-expand-icon') - .first() - .simulate('click'); + wrapper.find('.rc-table-row-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(false, data[0]); expect(onExpand).toHaveBeenCalledTimes(2); }); @@ -486,16 +415,10 @@ describe('Table.Expand', () => { data, }), ); - wrapper - .find('.custom-expand-icon') - .first() - .simulate('click'); + wrapper.find('.custom-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(true, data[0]); expect(onExpand).toHaveBeenCalledTimes(1); - wrapper - .find('.custom-expand-icon') - .first() - .simulate('click'); + wrapper.find('.custom-expand-icon').first().simulate('click'); expect(onExpand).toHaveBeenCalledWith(false, data[0]); expect(onExpand).toHaveBeenCalledTimes(2); }); diff --git a/tests/FixedColumn.spec.js b/tests/FixedColumn.spec.js index ae4bc9e47..239eb71a5 100644 --- a/tests/FixedColumn.spec.js +++ b/tests/FixedColumn.spec.js @@ -36,28 +36,29 @@ describe('Table.FixedColumn', () => { { scrollName: 'scrollX', scroll: { x: 1200 } }, { scrollName: 'scrollXY', scroll: { x: 1200, y: 100 } }, ].forEach(({ scrollName, scroll }) => { - [{ name: 'with data', data }, { name: 'without data', data: [] }].forEach( - ({ name, data: testData }) => { - it(`${scrollName} - ${name}`, () => { - jest.useFakeTimers(); - const wrapper = mount(
); - - act(() => { - wrapper - .find('table ResizeObserver') - .first() - .props() - .onResize({ width: 93, offsetWidth: 93 }); - }); - act(() => { - jest.runAllTimers(); - wrapper.update(); - }); - expect(wrapper.render()).toMatchSnapshot(); - jest.useRealTimers(); + [ + { name: 'with data', data }, + { name: 'without data', data: [] }, + ].forEach(({ name, data: testData }) => { + it(`${scrollName} - ${name}`, () => { + jest.useFakeTimers(); + const wrapper = mount(
); + + act(() => { + wrapper + .find('table ResizeObserver') + .first() + .props() + .onResize({ width: 93, offsetWidth: 93 }); }); - }, - ); + act(() => { + jest.runAllTimers(); + wrapper.update(); + }); + expect(wrapper.render()).toMatchSnapshot(); + jest.useRealTimers(); + }); + }); }); }); diff --git a/tests/FixedHeader.spec.js b/tests/FixedHeader.spec.js index 36ab93cc4..bcc426213 100644 --- a/tests/FixedHeader.spec.js +++ b/tests/FixedHeader.spec.js @@ -17,21 +17,9 @@ describe('Table.FixedHeader', () => { />, ); - wrapper - .find('ResizeObserver') - .at(0) - .props() - .onResize({ width: 100, offsetWidth: 100 }); - wrapper - .find('ResizeObserver') - .at(1) - .props() - .onResize({ width: 200, offsetWidth: 200 }); - wrapper - .find('ResizeObserver') - .at(2) - .props() - .onResize({ width: 0, offsetWidth: 0 }); + wrapper.find('ResizeObserver').at(0).props().onResize({ width: 100, offsetWidth: 100 }); + wrapper.find('ResizeObserver').at(1).props().onResize({ width: 200, offsetWidth: 200 }); + wrapper.find('ResizeObserver').at(2).props().onResize({ width: 0, offsetWidth: 0 }); act(() => { jest.runAllTimers(); @@ -41,41 +29,16 @@ describe('Table.FixedHeader', () => { expect(wrapper.find('.rc-table-header table').props().style.visibility).toBeFalsy(); expect(); - expect( - wrapper - .find('colgroup col') - .at(0) - .props().style.width, - ).toEqual(100); - expect( - wrapper - .find('colgroup col') - .at(1) - .props().style.width, - ).toEqual(200); - expect( - wrapper - .find('colgroup col') - .at(2) - .props().style.width, - ).toEqual(0); + expect(wrapper.find('colgroup col').at(0).props().style.width).toEqual(100); + expect(wrapper.find('colgroup col').at(1).props().style.width).toEqual(200); + expect(wrapper.find('colgroup col').at(2).props().style.width).toEqual(0); // Update columns wrapper.setProps({ columns: [col2, col1] }); wrapper.update(); - expect( - wrapper - .find('colgroup col') - .at(0) - .props().style.width, - ).toEqual(200); - expect( - wrapper - .find('colgroup col') - .at(1) - .props().style.width, - ).toEqual(100); + expect(wrapper.find('colgroup col').at(0).props().style.width).toEqual(200); + expect(wrapper.find('colgroup col').at(1).props().style.width).toEqual(100); jest.useRealTimers(); }); @@ -95,22 +58,12 @@ describe('Table.FixedHeader', () => { />, ); - expect( - wrapper - .find('table') - .last() - .find('colgroup col') - .first() - .props().className, - ).toEqual('test-internal'); - expect( - wrapper - .find('table') - .first() - .find('colgroup col') - .first() - .props().className, - ).toEqual('test-internal'); + expect(wrapper.find('table').last().find('colgroup col').first().props().className).toEqual( + 'test-internal', + ); + expect(wrapper.find('table').first().find('colgroup col').first().props().className).toEqual( + 'test-internal', + ); }); it('show header when data is null', () => { diff --git a/tests/Scroll.spec.js b/tests/Scroll.spec.js index b165c4974..2ba32d3cf 100644 --- a/tests/Scroll.spec.js +++ b/tests/Scroll.spec.js @@ -5,7 +5,10 @@ import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; import Table from '../src'; describe('Table.Scroll', () => { - const data = [{ key: 'key0', name: 'Lucy' }, { key: 'key1', name: 'Jack' }]; + const data = [ + { key: 'key0', name: 'Lucy' }, + { key: 'key1', name: 'Jack' }, + ]; const createTable = props => { const columns = [{ title: 'Name', dataIndex: 'name', key: 'name' }]; diff --git a/tests/Table.spec.js b/tests/Table.spec.js index 0d3128629..566a4670d 100644 --- a/tests/Table.spec.js +++ b/tests/Table.spec.js @@ -5,7 +5,10 @@ import Table from '../src'; import { INTERNAL_HOOKS } from '../src/Table'; describe('Table.Basic', () => { - const data = [{ key: 'key0', name: 'Lucy' }, { key: 'key1', name: 'Jack' }]; + const data = [ + { key: 'key0', name: 'Lucy' }, + { key: 'key1', name: 'Jack' }, + ]; const createTable = props => { const columns = [{ title: 'Name', dataIndex: 'name', key: 'name' }]; @@ -59,18 +62,8 @@ describe('Table.Basic', () => { }), ); expect(wrapper.render()).toMatchSnapshot(); - expect( - wrapper - .find('th') - .at(0) - .text(), - ).toEqual('姓名'); - expect( - wrapper - .find('th') - .at(1) - .text(), - ).toEqual('年龄'); + expect(wrapper.find('th').at(0).text()).toEqual('姓名'); + expect(wrapper.find('th').at(1).text()).toEqual('年龄'); }); it('falsy columns', () => { @@ -94,22 +87,12 @@ describe('Table.Basic', () => { describe('renders empty text correctly', () => { it('ReactNode', () => { const wrapper = mount(createTable({ data: [], emptyText: 'No data' })); - expect( - wrapper - .find('.rc-table-placeholder') - .hostNodes() - .text(), - ).toEqual('No data'); + expect(wrapper.find('.rc-table-placeholder').hostNodes().text()).toEqual('No data'); }); it('renderProps', () => { const wrapper = mount(createTable({ data: [], emptyText: () => 'No data' })); - expect( - wrapper - .find('.rc-table-placeholder') - .hostNodes() - .text(), - ).toEqual('No data'); + expect(wrapper.find('.rc-table-placeholder').hostNodes().text()).toEqual('No data'); }); it('effect update', () => { @@ -122,12 +105,7 @@ describe('Table.Basic', () => { }; const wrapper = mount(); wrapper.update(); - expect( - wrapper - .find('.rc-table-placeholder') - .hostNodes() - .text(), - ).toEqual('bamboo'); + expect(wrapper.find('.rc-table-placeholder').hostNodes().text()).toEqual('bamboo'); }); }); @@ -143,22 +121,12 @@ describe('Table.Basic', () => { it('renders title correctly', () => { const wrapper = mount(createTable({ title: () =>

title

})); - expect( - wrapper - .find('.rc-table-title') - .hostNodes() - .text(), - ).toEqual('title'); + expect(wrapper.find('.rc-table-title').hostNodes().text()).toEqual('title'); }); it('renders footer correctly', () => { const wrapper = mount(createTable({ footer: () =>

footer

})); - expect( - wrapper - .find('.rc-table-footer') - .hostNodes() - .text(), - ).toEqual('footer'); + expect(wrapper.find('.rc-table-footer').hostNodes().text()).toEqual('footer'); }); describe('summary', () => { @@ -216,50 +184,20 @@ describe('Table.Basic', () => { describe('rowKey', () => { it('uses record.key', () => { const wrapper = mount(createTable()); - expect( - wrapper - .find('BodyRow') - .at(0) - .key(), - ).toBe('key0'); - expect( - wrapper - .find('BodyRow') - .at(1) - .key(), - ).toBe('key1'); + expect(wrapper.find('BodyRow').at(0).key()).toBe('key0'); + expect(wrapper.find('BodyRow').at(1).key()).toBe('key1'); }); it('sets by rowKey', () => { const wrapper = mount(createTable({ rowKey: 'name' })); - expect( - wrapper - .find('BodyRow') - .at(0) - .key(), - ).toBe('Lucy'); - expect( - wrapper - .find('BodyRow') - .at(1) - .key(), - ).toBe('Jack'); + expect(wrapper.find('BodyRow').at(0).key()).toBe('Lucy'); + expect(wrapper.find('BodyRow').at(1).key()).toBe('Jack'); }); it('sets by rowKey function', () => { const wrapper = mount(createTable({ rowKey: record => `${record.key}1` })); - expect( - wrapper - .find('BodyRow') - .at(0) - .key(), - ).toBe('key01'); - expect( - wrapper - .find('BodyRow') - .at(1) - .key(), - ).toBe('key11'); + expect(wrapper.find('BodyRow').at(0).key()).toBe('key01'); + expect(wrapper.find('BodyRow').at(1).key()).toBe('key11'); }); }); @@ -380,7 +318,10 @@ describe('Table.Basic', () => { ]; const wrapper = mount(createTable({ columns, data: localData })); - const targetData = [['John', 'Doe'], ['Terry', 'Garner']]; + const targetData = [ + ['John', 'Doe'], + ['Terry', 'Garner'], + ]; wrapper.find('tbody tr').forEach((tr, ri) => { tr.find('td').forEach((td, di) => { @@ -391,14 +332,12 @@ describe('Table.Basic', () => { }); it('render empty cell if text is empty object', () => { - const localData = [{ key: 'key0', name: {} }, { key: 'key1', name: 'Jack' }]; + const localData = [ + { key: 'key0', name: {} }, + { key: 'key1', name: 'Jack' }, + ]; const wrapper = mount(createTable({ data: localData })); - expect( - wrapper - .find('table td') - .first() - .text(), - ).toBe(''); + expect(wrapper.find('table td').first().text()).toBe(''); }); it('renders colSpan correctly', () => { @@ -570,10 +509,7 @@ describe('Table.Basic', () => { }; const wrapper = mount(); for (let i = 0; i < 10; i += 1) { - wrapper - .find('tbody tr td') - .last() - .simulate('click'); + wrapper.find('tbody tr td').last().simulate('click'); expect(wrapper.find('#count').text()).toEqual(String(i + 1)); } }); @@ -706,34 +642,12 @@ describe('Table.Basic', () => { { title: 'Age', dataIndex: 'age', key: 'age', align: 'center' }, ]; const wrapper = mount(createTable({ columns })); - expect( - wrapper - .find('th') - .at(0) - .props().style.textAlign, - ).toBeFalsy(); - expect( - wrapper - .find('th') - .at(1) - .props().style.textAlign, - ).toEqual('center'); - expect( - wrapper - .find('tbody tr') - .first() - .find('td') - .at(0) - .props().style.textAlign, - ).toBeFalsy(); - expect( - wrapper - .find('tbody tr') - .first() - .find('td') - .at(1) - .props().style.textAlign, - ).toEqual('center'); + expect(wrapper.find('th').at(0).props().style.textAlign).toBeFalsy(); + expect(wrapper.find('th').at(1).props().style.textAlign).toEqual('center'); + expect(wrapper.find('tbody tr').first().find('td').at(0).props().style.textAlign).toBeFalsy(); + expect(wrapper.find('tbody tr').first().find('td').at(1).props().style.textAlign).toEqual( + 'center', + ); }); it('align column should not override cell style', () => { @@ -748,21 +662,11 @@ describe('Table.Basic', () => { }, ]; const wrapper = mount(createTable({ columns })); - expect( - wrapper - .find('th') - .first() - .props().style, - ).toEqual({ + expect(wrapper.find('th').first().props().style).toEqual({ color: 'green', textAlign: 'center', }); - expect( - wrapper - .find('td') - .first() - .props().style, - ).toEqual({ + expect(wrapper.find('td').first().props().style).toEqual({ color: 'red', textAlign: 'center', }); @@ -866,12 +770,7 @@ describe('Table.Basic', () => { }), ); - expect( - wrapper - .find('tbody Cell') - .first() - .key(), - ).toBeTruthy(); + expect(wrapper.find('tbody Cell').first().key()).toBeTruthy(); }); it('syntactic sugar', () => { @@ -937,12 +836,7 @@ describe('Table.Basic', () => { />, ); - expect( - wrapper - .find('tr') - .last() - .props()['data-row-key'], - ).toEqual('light'); + expect(wrapper.find('tr').last().props()['data-row-key']).toEqual('light'); }); it('render with state change', () => {