Skip to content

Commit 0e8981c

Browse files
committed
test: fix render empty test case
1 parent 0c2e751 commit 0e8981c

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

tests/FixedColumn.spec.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mount } from 'enzyme';
22
import RcResizeObserver from 'rc-resize-observer';
3-
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
3+
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
44
import { resetWarned } from 'rc-util/lib/warning';
55
import { act } from 'react-dom/test-utils';
66
import Table from '../src';
@@ -9,8 +9,13 @@ describe('Table.FixedColumn', () => {
99
let domSpy;
1010

1111
beforeAll(() => {
12-
domSpy = spyElementPrototype(HTMLElement, 'offsetParent', {
13-
get: () => ({}),
12+
domSpy = spyElementPrototypes(HTMLElement, {
13+
offsetParent: {
14+
get: () => ({}),
15+
},
16+
offsetWidth: {
17+
get: () => 1000,
18+
},
1419
});
1520
});
1621

@@ -65,6 +70,10 @@ describe('Table.FixedColumn', () => {
6570
jest.useFakeTimers();
6671
const wrapper = mount(<Table columns={columns} data={testData} scroll={scroll} />);
6772

73+
act(() => {
74+
wrapper.find(RcResizeObserver).first().props().onResize({ width: 100 });
75+
});
76+
6877
act(() => {
6978
wrapper
7079
.find(RcResizeObserver.Collection)

tests/__snapshots__/FixedColumn.spec.js.snap

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,8 +1759,10 @@ exports[`Table.FixedColumn renders correctly scrollX - without data 1`] = `
17591759
>
17601760
<div
17611761
class="rc-table-expanded-row-fixed"
1762-
style="width: 0px; position: sticky; left: 0px; overflow: hidden;"
1763-
/>
1762+
style="width: 1000px; position: sticky; left: 0px; overflow: hidden;"
1763+
>
1764+
No Data
1765+
</div>
17641766
</td>
17651767
</tr>
17661768
</tbody>
@@ -1789,37 +1791,37 @@ exports[`Table.FixedColumn renders correctly scrollXY - with data 1`] = `
17891791
style="width: 93px;"
17901792
/>
17911793
<col
1792-
style="width: 0px;"
1794+
style="width: 1000px;"
17931795
/>
17941796
<col
1795-
style="width: 0px;"
1797+
style="width: 1000px;"
17961798
/>
17971799
<col
1798-
style="width: 0px;"
1800+
style="width: 1000px;"
17991801
/>
18001802
<col
1801-
style="width: 0px;"
1803+
style="width: 1000px;"
18021804
/>
18031805
<col
1804-
style="width: 0px;"
1806+
style="width: 1000px;"
18051807
/>
18061808
<col
1807-
style="width: 0px;"
1809+
style="width: 1000px;"
18081810
/>
18091811
<col
1810-
style="width: 0px;"
1812+
style="width: 1000px;"
18111813
/>
18121814
<col
1813-
style="width: 0px;"
1815+
style="width: 1000px;"
18141816
/>
18151817
<col
1816-
style="width: 0px;"
1818+
style="width: 1000px;"
18171819
/>
18181820
<col
1819-
style="width: 0px;"
1821+
style="width: 1000px;"
18201822
/>
18211823
<col
1822-
style="width: 0px;"
1824+
style="width: 1000px;"
18231825
/>
18241826
<col
18251827
style="width: 15px;"
@@ -2620,37 +2622,37 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
26202622
style="width: 93px;"
26212623
/>
26222624
<col
2623-
style="width: 0px;"
2625+
style="width: 1000px;"
26242626
/>
26252627
<col
2626-
style="width: 0px;"
2628+
style="width: 1000px;"
26272629
/>
26282630
<col
2629-
style="width: 0px;"
2631+
style="width: 1000px;"
26302632
/>
26312633
<col
2632-
style="width: 0px;"
2634+
style="width: 1000px;"
26332635
/>
26342636
<col
2635-
style="width: 0px;"
2637+
style="width: 1000px;"
26362638
/>
26372639
<col
2638-
style="width: 0px;"
2640+
style="width: 1000px;"
26392641
/>
26402642
<col
2641-
style="width: 0px;"
2643+
style="width: 1000px;"
26422644
/>
26432645
<col
2644-
style="width: 0px;"
2646+
style="width: 1000px;"
26452647
/>
26462648
<col
2647-
style="width: 0px;"
2649+
style="width: 1000px;"
26482650
/>
26492651
<col
2650-
style="width: 0px;"
2652+
style="width: 1000px;"
26512653
/>
26522654
<col
2653-
style="width: 0px;"
2655+
style="width: 1000px;"
26542656
/>
26552657
<col
26562658
style="width: 15px;"
@@ -2889,8 +2891,10 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
28892891
>
28902892
<div
28912893
class="rc-table-expanded-row-fixed"
2892-
style="width: -15px; position: sticky; left: 0px; overflow: hidden;"
2893-
/>
2894+
style="width: 985px; position: sticky; left: 0px; overflow: hidden;"
2895+
>
2896+
No Data
2897+
</div>
28942898
</td>
28952899
</tr>
28962900
</tbody>

0 commit comments

Comments
 (0)