Skip to content

Commit c67130b

Browse files
committed
✅ add test case for table data children
1 parent 6db8b06 commit c67130b

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed

tests/ExpandRow.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ describe('Table.Expand', () => {
5252
expect(wrapper.render()).toMatchSnapshot();
5353
});
5454

55+
it('renders tree row correctly with different children', () => {
56+
const data = [
57+
{
58+
key: 0,
59+
name: 'Lucy',
60+
age: 27,
61+
children: [{ key: 2, name: 'Jim', age: 1 }],
62+
},
63+
{ key: 1, name: 'Jack', age: 28 },
64+
{ key: 2, name: 'Jack', age: 28, children: null },
65+
{ key: 3, name: 'Jack', age: 28, children: [] },
66+
{ key: 4, name: 'Jack', age: 28, children: undefined },
67+
{ key: 5, name: 'Jack', age: 28, children: false },
68+
];
69+
const wrapper = mount(createTable({ data }));
70+
expect(wrapper.render()).toMatchSnapshot();
71+
});
72+
5573
it('childrenColumnName', () => {
5674
const data = [
5775
{

tests/__snapshots__/ExpandRow.spec.js.snap

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,164 @@ exports[`Table.Expand renders tree row correctly 1`] = `
350350
</div>
351351
</div>
352352
`;
353+
354+
exports[`Table.Expand renders tree row correctly with different children 1`] = `
355+
<div
356+
class="rc-table"
357+
>
358+
<div
359+
class="rc-table-container"
360+
>
361+
<div
362+
class="rc-table-content"
363+
>
364+
<table
365+
style="table-layout: auto;"
366+
>
367+
<colgroup>
368+
<col />
369+
<col />
370+
</colgroup>
371+
<thead>
372+
<tr>
373+
<th
374+
class="rc-table-cell"
375+
>
376+
Name
377+
</th>
378+
<th
379+
class="rc-table-cell"
380+
>
381+
Age
382+
</th>
383+
</tr>
384+
</thead>
385+
<tbody
386+
class="rc-table-tbody"
387+
>
388+
<tr
389+
class="rc-table-row rc-table-row-level-0"
390+
>
391+
<td
392+
class="rc-table-cell rc-table-cell-with-append"
393+
>
394+
<span
395+
class="rc-table-row-indent indent-level-0"
396+
/>
397+
<span
398+
class="rc-table-row-expand-icon rc-table-row-collapsed"
399+
/>
400+
Lucy
401+
</td>
402+
<td
403+
class="rc-table-cell"
404+
>
405+
27
406+
</td>
407+
</tr>
408+
<tr
409+
class="rc-table-row rc-table-row-level-0"
410+
>
411+
<td
412+
class="rc-table-cell rc-table-cell-with-append"
413+
>
414+
<span
415+
class="rc-table-row-indent indent-level-0"
416+
/>
417+
<span
418+
class="rc-table-row-expand-icon rc-table-row-spaced"
419+
/>
420+
Jack
421+
</td>
422+
<td
423+
class="rc-table-cell"
424+
>
425+
28
426+
</td>
427+
</tr>
428+
<tr
429+
class="rc-table-row rc-table-row-level-0"
430+
>
431+
<td
432+
class="rc-table-cell rc-table-cell-with-append"
433+
>
434+
<span
435+
class="rc-table-row-indent indent-level-0"
436+
/>
437+
<span
438+
class="rc-table-row-expand-icon rc-table-row-spaced"
439+
/>
440+
Jack
441+
</td>
442+
<td
443+
class="rc-table-cell"
444+
>
445+
28
446+
</td>
447+
</tr>
448+
<tr
449+
class="rc-table-row rc-table-row-level-0"
450+
>
451+
<td
452+
class="rc-table-cell rc-table-cell-with-append"
453+
>
454+
<span
455+
class="rc-table-row-indent indent-level-0"
456+
/>
457+
<span
458+
class="rc-table-row-expand-icon rc-table-row-collapsed"
459+
/>
460+
Jack
461+
</td>
462+
<td
463+
class="rc-table-cell"
464+
>
465+
28
466+
</td>
467+
</tr>
468+
<tr
469+
class="rc-table-row rc-table-row-level-0"
470+
>
471+
<td
472+
class="rc-table-cell rc-table-cell-with-append"
473+
>
474+
<span
475+
class="rc-table-row-indent indent-level-0"
476+
/>
477+
<span
478+
class="rc-table-row-expand-icon rc-table-row-spaced"
479+
/>
480+
Jack
481+
</td>
482+
<td
483+
class="rc-table-cell"
484+
>
485+
28
486+
</td>
487+
</tr>
488+
<tr
489+
class="rc-table-row rc-table-row-level-0"
490+
>
491+
<td
492+
class="rc-table-cell rc-table-cell-with-append"
493+
>
494+
<span
495+
class="rc-table-row-indent indent-level-0"
496+
/>
497+
<span
498+
class="rc-table-row-expand-icon rc-table-row-spaced"
499+
/>
500+
Jack
501+
</td>
502+
<td
503+
class="rc-table-cell"
504+
>
505+
28
506+
</td>
507+
</tr>
508+
</tbody>
509+
</table>
510+
</div>
511+
</div>
512+
</div>
513+
`;

0 commit comments

Comments
 (0)