From a94e3ab3e0b6b75cf863bae2f4f01f9891a68934 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 27 Aug 2017 17:29:51 +0800 Subject: [PATCH] Add test case for empty table --- .../__snapshots__/empty.test.js.snap | 529 ++++++++++++++++++ components/table/__tests__/empty.test.js | 61 ++ 2 files changed, 590 insertions(+) create mode 100644 components/table/__tests__/__snapshots__/empty.test.js.snap create mode 100644 components/table/__tests__/empty.test.js diff --git a/components/table/__tests__/__snapshots__/empty.test.js.snap b/components/table/__tests__/__snapshots__/empty.test.js.snap new file mode 100644 index 0000000000..9fef31fd00 --- /dev/null +++ b/components/table/__tests__/__snapshots__/empty.test.js.snap @@ -0,0 +1,529 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Table renders empty table 1`] = ` +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + Column 1 + + + + Column 2 + + + + Column 3 + + + + Column 4 + + + + Column 5 + + + + Column 6 + + + + Column 7 + + + + Column 8 + +
+
+
+ + + 暂无数据 + +
+
+
+
+
+
+`; + +exports[`Table renders empty table with custom emptyText 1`] = ` +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + Column 1 + + + + Column 2 + + + + Column 3 + + + + Column 4 + + + + Column 5 + + + + Column 6 + + + + Column 7 + + + + Column 8 + +
+
+
+ custom empty text +
+
+
+
+
+
+`; + +exports[`Table renders empty table with fixed columns 1`] = ` +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Full Name + + + + Age + + + + Column 1 + + + + Column 2 + + + + Column 3 + + + + Column 4 + + + + Column 5 + + + + Column 6 + + + + Column 7 + + + + Column 8 + + + + Action + +
+ + + + + + + + + + + +
+
+
+ + + 暂无数据 + +
+
+
+
+
+ + + + + + + + + + + + + + + + +
+ + Full Name + + + + Age + +
+ + +
+
+
+
+
+
+
+ + + + + + + + + + + + + +
+ + Action + +
+
+
+
+
+
+
+
+
+
+`; diff --git a/components/table/__tests__/empty.test.js b/components/table/__tests__/empty.test.js new file mode 100644 index 0000000000..54ec88b0ed --- /dev/null +++ b/components/table/__tests__/empty.test.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { render } from 'enzyme'; +import Table from '..'; + +const columns = [ + { title: 'Column 1', dataIndex: 'address', key: '1' }, + { title: 'Column 2', dataIndex: 'address', key: '2' }, + { title: 'Column 3', dataIndex: 'address', key: '3' }, + { title: 'Column 4', dataIndex: 'address', key: '4' }, + { title: 'Column 5', dataIndex: 'address', key: '5' }, + { title: 'Column 6', dataIndex: 'address', key: '6' }, + { title: 'Column 7', dataIndex: 'address', key: '7' }, + { title: 'Column 8', dataIndex: 'address', key: '8' }, +]; + +const columnsFixed = [ + { title: 'Full Name', width: 100, dataIndex: 'name', key: 'name', fixed: 'left' }, + { title: 'Age', width: 100, dataIndex: 'age', key: 'age', fixed: 'left' }, + { title: 'Column 1', dataIndex: 'address', key: '1' }, + { title: 'Column 2', dataIndex: 'address', key: '2' }, + { title: 'Column 3', dataIndex: 'address', key: '3' }, + { title: 'Column 4', dataIndex: 'address', key: '4' }, + { title: 'Column 5', dataIndex: 'address', key: '5' }, + { title: 'Column 6', dataIndex: 'address', key: '6' }, + { title: 'Column 7', dataIndex: 'address', key: '7' }, + { title: 'Column 8', dataIndex: 'address', key: '8' }, + { + title: 'Action', + key: 'address', + fixed: 'right', + width: 100, + }, +]; + +describe('Table', () => { + it('renders empty table', () => { + const wrapper = render( + + ); + expect(wrapper).toMatchSnapshot(); + }); + + it('renders empty table with fixed columns', () => { + const wrapper = render( +
+ ); + expect(wrapper).toMatchSnapshot(); + }); + + it('renders empty table with custom emptyText', () => { + const wrapper = render( +
+ ); + expect(wrapper).toMatchSnapshot(); + }); +}); -- GitLab