@@ -2,6 +2,7 @@ import React from 'react';
22import { mount } from 'enzyme' ;
33import { act } from 'react-dom/test-utils' ;
44import { resetWarned } from 'rc-util/lib/warning' ;
5+ import { spyElementPrototype } from 'rc-util/lib/test/domHook' ;
56import Table from '../src' ;
67
78describe ( 'Table.Expand' , ( ) => {
@@ -87,33 +88,47 @@ describe('Table.Expand', () => {
8788 expect ( wrapper . render ( ) ) . toMatchSnapshot ( ) ;
8889 } ) ;
8990
90- it ( 'renders fixed column correctly' , ( ) => {
91- const columns = [
92- { title : 'Name' , dataIndex : 'name' , key : 'name' , fixed : true } ,
93- { title : 'Age' , dataIndex : 'age' , key : 'age' } ,
94- { title : 'Gender' , dataIndex : 'gender' , key : 'gender' , fixed : 'right' } ,
95- ] ;
96- const data = [
97- { key : 0 , name : 'Lucy' , age : 27 , gender : 'F' } ,
98- { key : 1 , name : 'Jack' , age : 28 , gender : 'M' } ,
99- ] ;
100- const wrapper = mount (
101- createTable ( {
102- columns,
103- data,
104- scroll : { x : 903 } ,
105- expandable : { expandedRowRender, defaultExpandAllRows : true } ,
106- } ) ,
107- ) ;
108- act ( ( ) => {
109- wrapper
110- . find ( 'ResizeObserver' )
111- . first ( )
112- . props ( )
113- . onResize ( { width : 1128 } ) ;
91+ describe ( 'renders fixed column correctly' , ( ) => {
92+ let domSpy ;
93+
94+ beforeAll ( ( ) => {
95+ domSpy = spyElementPrototype ( HTMLDivElement , 'offsetWidth' , {
96+ get : ( ) => 1128 ,
97+ } ) ;
98+ } ) ;
99+
100+ afterAll ( ( ) => {
101+ domSpy . mockRestore ( ) ;
102+ } ) ;
103+
104+ it ( 'work' , ( ) => {
105+ const columns = [
106+ { title : 'Name' , dataIndex : 'name' , key : 'name' , fixed : true } ,
107+ { title : 'Age' , dataIndex : 'age' , key : 'age' } ,
108+ { title : 'Gender' , dataIndex : 'gender' , key : 'gender' , fixed : 'right' } ,
109+ ] ;
110+ const data = [
111+ { key : 0 , name : 'Lucy' , age : 27 , gender : 'F' } ,
112+ { key : 1 , name : 'Jack' , age : 28 , gender : 'M' } ,
113+ ] ;
114+ const wrapper = mount (
115+ createTable ( {
116+ columns,
117+ data,
118+ scroll : { x : 903 } ,
119+ expandable : { expandedRowRender, defaultExpandAllRows : true } ,
120+ } ) ,
121+ ) ;
122+ act ( ( ) => {
123+ wrapper
124+ . find ( 'ResizeObserver' )
125+ . first ( )
126+ . props ( )
127+ . onResize ( { width : 1128 } ) ;
128+ } ) ;
129+ wrapper . update ( ) ;
130+ expect ( wrapper . render ( ) ) . toMatchSnapshot ( ) ;
114131 } ) ;
115- wrapper . update ( ) ;
116- expect ( wrapper . render ( ) ) . toMatchSnapshot ( ) ;
117132 } ) ;
118133
119134 it ( 'renders expand icon to the specify column' , ( ) => {
0 commit comments