Skip to content

Commit b0654a3

Browse files
committed
Update snapshot
1 parent 64a7ac2 commit b0654a3

File tree

5 files changed

+121
-2242
lines changed

5 files changed

+121
-2242
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
],
6363
"transform": {
6464
"\\.jsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js"
65-
}
65+
},
66+
"snapshotSerializers": [
67+
"enzyme-to-json/serializer"
68+
]
6669
},
6770
"dependencies": {
6871
"babel-runtime": "6.x",
@@ -86,7 +89,6 @@
8689
"rc-menu": "^5.0.11",
8790
"rc-tools": "7.x",
8891
"react": "^16.0.0",
89-
"react-addons-test-utils": "^15.3.1",
9092
"react-dom": "^16.0.0",
9193
"react-test-renderer": "^16.0.0"
9294
},

tests/Table.expandRow.spec.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-undef */
22
import React from 'react';
33
import { render, mount } from 'enzyme';
4-
import { renderToJson, mountToJson } from 'enzyme-to-json';
54
import Table from '../src';
65

76
describe('Table.expand', () => {
@@ -24,7 +23,7 @@ describe('Table.expand', () => {
2423

2524
it('renders expand row correctly', () => {
2625
const wrapper = render(createTable({ expandedRowRender }));
27-
expect(renderToJson(wrapper)).toMatchSnapshot();
26+
expect(wrapper).toMatchSnapshot();
2827
});
2928

3029
it('renders tree row correctly', () => {
@@ -35,23 +34,23 @@ describe('Table.expand', () => {
3534
{ key: 1, name: 'Jack', age: 28 },
3635
];
3736
const wrapper = render(createTable({ data: localData }));
38-
expect(renderToJson(wrapper)).toMatchSnapshot();
37+
expect(wrapper).toMatchSnapshot();
3938
});
4039

4140
it('renders expand icon as cell', () => {
4241
const wrapper = render(createTable({
4342
expandedRowRender,
4443
expandIconAsCell: true,
4544
}));
46-
expect(renderToJson(wrapper)).toMatchSnapshot();
45+
expect(wrapper).toMatchSnapshot();
4746
});
4847

4948
it('renders expand icon to the specify column', () => {
5049
const wrapper = render(createTable({
5150
expandedRowRender,
5251
expandIconColumnIndex: 1,
5352
}));
54-
expect(renderToJson(wrapper)).toMatchSnapshot();
53+
expect(wrapper).toMatchSnapshot();
5554
});
5655

5756
it('renders nested data correctly', () => {
@@ -71,33 +70,33 @@ describe('Table.expand', () => {
7170
},
7271
];
7372
const wrapper = render(createTable({ data: localData }));
74-
expect(renderToJson(wrapper)).toMatchSnapshot();
73+
expect(wrapper).toMatchSnapshot();
7574
});
7675

7776
it('expand all rows by default', () => {
7877
const wrapper = render(createTable({
7978
expandedRowRender,
8079
defaultExpandAllRows: true,
8180
}));
82-
expect(renderToJson(wrapper)).toMatchSnapshot();
81+
expect(wrapper).toMatchSnapshot();
8382
});
8483

8584
it('expand rows by defaultExpandedRowKeys', () => {
8685
const wrapper = render(createTable({
8786
expandedRowRender,
8887
defaultExpandedRowKeys: [1],
8988
}));
90-
expect(renderToJson(wrapper)).toMatchSnapshot();
89+
expect(wrapper).toMatchSnapshot();
9190
});
9291

9392
it('controlled by expandedRowKeys', () => {
9493
const wrapper = mount(createTable({
9594
expandedRowRender,
9695
expandedRowKeys: [0],
9796
}));
98-
expect(mountToJson(wrapper)).toMatchSnapshot();
97+
expect(wrapper.render()).toMatchSnapshot();
9998
wrapper.setProps({ expandedRowKeys: [1] });
100-
expect(mountToJson(wrapper)).toMatchSnapshot();
99+
expect(wrapper.render()).toMatchSnapshot();
101100
});
102101

103102
it('renders expend row class correctly', () => {
@@ -107,7 +106,7 @@ describe('Table.expand', () => {
107106
expandedRowKeys: [0],
108107
expandedRowClassName,
109108
}));
110-
expect(renderToJson(wrapper)).toMatchSnapshot();
109+
expect(wrapper).toMatchSnapshot();
111110
expect(expandedRowClassName).toBeCalledWith(data[0], 0, 0);
112111
});
113112

@@ -149,6 +148,6 @@ describe('Table.expand', () => {
149148
fit('expand row by click', () => {
150149
const wrapper = mount(createTable({ expandedRowRender }));
151150
wrapper.find('ExpandIcon').first().simulate('click');
152-
expect(mountToJson(wrapper)).toMatchSnapshot();
151+
expect(wrapper.render()).toMatchSnapshot();
153152
});
154153
});

tests/Table.fixedColumns.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-undef */
22
import React from 'react';
33
import { render, mount } from 'enzyme';
4-
import { renderToJson } from 'enzyme-to-json';
54
import Table from '../src';
65

76
describe('Table.fixedColumns', () => {
@@ -47,7 +46,7 @@ describe('Table.fixedColumns', () => {
4746
scroll={{ x: 1200 }}
4847
/>
4948
);
50-
expect(renderToJson(wrapper)).toMatchSnapshot();
49+
expect(wrapper).toMatchSnapshot();
5150
});
5251

5352
it('toggles hover class when user hovering', () => {

tests/Table.spec.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-undef, no-console */
22
import React from 'react';
33
import { render, mount } from 'enzyme';
4-
import { renderToJson } from 'enzyme-to-json';
54
import Table from '../src';
65

76
describe('Table', () => {
@@ -28,34 +27,34 @@ describe('Table', () => {
2827
prefixCls: 'test-prefix',
2928
className: 'test-class-name',
3029
}));
31-
expect(renderToJson(wrapper)).toMatchSnapshot();
30+
expect(wrapper).toMatchSnapshot();
3231
});
3332

3433
it('renders empty text correctly', () => {
3534
const wrapper1 = render(createTable({ data: [], emptyText: 'No data' }));
3635
const wrapper2 = render(createTable({ data: [], emptyText: () => 'No data' }));
37-
expect(renderToJson(wrapper1)).toMatchSnapshot();
38-
expect(renderToJson(wrapper2)).toMatchSnapshot();
36+
expect(wrapper1).toMatchSnapshot();
37+
expect(wrapper2).toMatchSnapshot();
3938
});
4039

4140
it('renders without header', () => {
4241
const wrapper = render(createTable({ showHeader: false }));
43-
expect(renderToJson(wrapper)).toMatchSnapshot();
42+
expect(wrapper).toMatchSnapshot();
4443
});
4544

4645
it('renders fixed header correctly', () => {
4746
const wrapper = render(createTable({ useFixedHeader: true }));
48-
expect(renderToJson(wrapper)).toMatchSnapshot();
47+
expect(wrapper).toMatchSnapshot();
4948
});
5049

5150
it('renders title correctly', () => {
5251
const wrapper = render(createTable({ title: () => <p>title</p> }));
53-
expect(renderToJson(wrapper)).toMatchSnapshot();
52+
expect(wrapper).toMatchSnapshot();
5453
});
5554

5655
it('renders footer correctly', () => {
5756
const wrapper = render(createTable({ footer: () => <p>footer</p> }));
58-
expect(renderToJson(wrapper)).toMatchSnapshot();
57+
expect(wrapper).toMatchSnapshot();
5958
});
6059

6160
it('renders table body to the wrapper', () => {
@@ -65,7 +64,7 @@ describe('Table', () => {
6564
</tbody>
6665
);
6766
const wrapper = render(createTable({ getBodyWrapper }));
68-
expect(renderToJson(wrapper)).toMatchSnapshot();
67+
expect(wrapper).toMatchSnapshot();
6968
});
7069

7170
xit('sets row refs', () => {
@@ -97,17 +96,17 @@ describe('Table', () => {
9796
describe('scroll', () => {
9897
it('renders scroll.x is true', () => {
9998
const wrapper = render(createTable({ scroll: { x: true } }));
100-
expect(renderToJson(wrapper)).toMatchSnapshot();
99+
expect(wrapper).toMatchSnapshot();
101100
});
102101

103102
it('renders scroll.x is a number', () => {
104103
const wrapper = render(createTable({ scroll: { x: 200 } }));
105-
expect(renderToJson(wrapper)).toMatchSnapshot();
104+
expect(wrapper).toMatchSnapshot();
106105
});
107106

108107
it('renders scroll.y is a number', () => {
109108
const wrapper = render(createTable({ scroll: { y: 200 } }));
110-
expect(renderToJson(wrapper)).toMatchSnapshot();
109+
expect(wrapper).toMatchSnapshot();
111110
});
112111

113112
it('fire scroll event', () => {
@@ -227,7 +226,7 @@ describe('Table', () => {
227226
},
228227
];
229228
const wrapper = render(createTable({ columns }));
230-
expect(renderToJson(wrapper)).toMatchSnapshot();
229+
expect(wrapper).toMatchSnapshot();
231230
});
232231

233232
it('renders custom cell correctly', () => {
@@ -240,7 +239,7 @@ describe('Table', () => {
240239
},
241240
];
242241
const wrapper = render(createTable({ columns }));
243-
expect(renderToJson(wrapper)).toMatchSnapshot();
242+
expect(wrapper).toMatchSnapshot();
244243
});
245244

246245
it('fires cell click event', () => {
@@ -286,7 +285,7 @@ describe('Table', () => {
286285
{ key: 'key1', name: { first: 'Terry', last: 'Garner' } },
287286
];
288287
const wrapper = render(createTable({ columns, data: localData }));
289-
expect(renderToJson(wrapper)).toMatchSnapshot();
288+
expect(wrapper).toMatchSnapshot();
290289
});
291290
});
292291

@@ -339,7 +338,7 @@ describe('Table', () => {
339338
{ key: 'key1', firstName: 'Terry', lastName: 'Garner' },
340339
];
341340
const wrapper = render(createTable({ columns, data: localData }));
342-
expect(renderToJson(wrapper)).toMatchSnapshot();
341+
expect(wrapper).toMatchSnapshot();
343342
});
344343

345344
it('renders rowSpan correctly', () => {
@@ -372,7 +371,7 @@ describe('Table', () => {
372371
{ key: 'key1', firstName: 'Terry', lastName: 'Garner' },
373372
];
374373
const wrapper = render(createTable({ columns, data: localData }));
375-
expect(renderToJson(wrapper)).toMatchSnapshot();
374+
expect(wrapper).toMatchSnapshot();
376375
});
377376

378377
it('shows error if no rowKey specify', () => {
@@ -432,13 +431,13 @@ describe('Table', () => {
432431
const wrapper = render(createTable({
433432
rowClassName: 'test-row-class-name-asStr',
434433
}));
435-
expect(renderToJson(wrapper)).toMatchSnapshot();
434+
expect(wrapper).toMatchSnapshot();
436435
});
437436

438437
it('renders correctly RowClassName as function', () => {
439438
const wrapper = render(createTable({
440439
rowClassName: () => 'test-row-class-name-asFn',
441440
}));
442-
expect(renderToJson(wrapper)).toMatchSnapshot();
441+
expect(wrapper).toMatchSnapshot();
443442
});
444443
});

0 commit comments

Comments
 (0)