Skip to content

Commit 3687070

Browse files
authored
fix: emptyText (#434)
1 parent 076add5 commit 3687070

File tree

4 files changed

+41
-54
lines changed

4 files changed

+41
-54
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ yarn.lock
3131
es/
3232
.storybook
3333
.doc
34-
!tests/__mocks__/rc-util/lib
34+
!tests/__mocks__/rc-util/lib
35+
examples/debug.tsx

examples/debug.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/Body/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function Body<RecordType>({
113113
getRowKey,
114114
getComponent,
115115
componentWidth,
116+
emptyNode,
116117
]);
117118
}
118119

tests/Table.spec.js

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,44 @@ describe('Table.Basic', () => {
4040
});
4141
});
4242

43-
it('renders empty text correctly', () => {
44-
const wrapper1 = mount(createTable({ data: [], emptyText: 'No data' }));
45-
const wrapper2 = mount(createTable({ data: [], emptyText: () => 'No data' }));
46-
expect(
47-
wrapper1
48-
.find('.rc-table-placeholder')
49-
.hostNodes()
50-
.text(),
51-
).toEqual('No data');
52-
expect(
53-
wrapper2
54-
.find('.rc-table-placeholder')
55-
.hostNodes()
56-
.text(),
57-
).toEqual('No data');
43+
describe('renders empty text correctly', () => {
44+
it('ReactNode', () => {
45+
const wrapper = mount(createTable({ data: [], emptyText: 'No data' }));
46+
expect(
47+
wrapper
48+
.find('.rc-table-placeholder')
49+
.hostNodes()
50+
.text(),
51+
).toEqual('No data');
52+
});
53+
54+
it('renderProps', () => {
55+
const wrapper = mount(createTable({ data: [], emptyText: () => 'No data' }));
56+
expect(
57+
wrapper
58+
.find('.rc-table-placeholder')
59+
.hostNodes()
60+
.text(),
61+
).toEqual('No data');
62+
});
63+
64+
it('effect update', () => {
65+
const App = () => {
66+
const [emptyText, setEmptyText] = React.useState('light');
67+
React.useEffect(() => {
68+
setEmptyText('bamboo');
69+
}, []);
70+
return <Table emptyText={emptyText} />;
71+
};
72+
const wrapper = mount(<App />);
73+
wrapper.update();
74+
expect(
75+
wrapper
76+
.find('.rc-table-placeholder')
77+
.hostNodes()
78+
.text(),
79+
).toEqual('bamboo');
80+
});
5881
});
5982

6083
it('renders without header', () => {

0 commit comments

Comments
 (0)