From 659bc01ac6f9a39f9fbe4456397bf605ea3825c1 Mon Sep 17 00:00:00 2001 From: franco Date: Sun, 12 Mar 2023 19:04:16 +0000 Subject: [PATCH] fix: table warning message when columns=[] --- src/Table.tsx | 17 +++++++++++------ tests/Table.spec.js | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Table.tsx b/src/Table.tsx index 8e74719e8..41d2cd877 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -570,11 +570,12 @@ function Table(tableProps: TableProps 0) { + warning( + false, + 'When use `components.body` with render props. Each column should have a fixed `width` value.', + ); + } return 0; }) as number[]; } else { @@ -599,7 +600,11 @@ function Table(tableProps: TableProps +
{summaryNode}
)} diff --git a/tests/Table.spec.js b/tests/Table.spec.js index cd1ca8fd3..8e4fec37d 100644 --- a/tests/Table.spec.js +++ b/tests/Table.spec.js @@ -701,6 +701,24 @@ describe('Table.Basic', () => { }); }); + it('without warning - columns is emplty', () => { + resetWarned(); + const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + mount( + createTable({ + columns: [], + components: { + body: () =>

Bamboo

, + }, + scroll: { x: 100, y: 100 }, + }), + ); + expect(errSpy).not.toHaveBeenCalledWith( + 'Warning: When use `components.body` with render props. Each column should have a fixed `width` value.', + ); + errSpy.mockRestore(); + }); + it('not crash', () => { const Looper = React.forwardRef(() => ); Looper.looper = Looper;