Skip to content

Commit

Permalink
✅ add test case for table data children
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Nov 20, 2019
1 parent 6db8b06 commit c67130b
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/ExpandRow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ describe('Table.Expand', () => {
expect(wrapper.render()).toMatchSnapshot();
});

it('renders tree row correctly with different children', () => {
const data = [
{
key: 0,
name: 'Lucy',
age: 27,
children: [{ key: 2, name: 'Jim', age: 1 }],
},
{ key: 1, name: 'Jack', age: 28 },
{ key: 2, name: 'Jack', age: 28, children: null },
{ key: 3, name: 'Jack', age: 28, children: [] },
{ key: 4, name: 'Jack', age: 28, children: undefined },
{ key: 5, name: 'Jack', age: 28, children: false },
];
const wrapper = mount(createTable({ data }));
expect(wrapper.render()).toMatchSnapshot();
});

it('childrenColumnName', () => {
const data = [
{
Expand Down
161 changes: 161 additions & 0 deletions tests/__snapshots__/ExpandRow.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,164 @@ exports[`Table.Expand renders tree row correctly 1`] = `
</div>
</div>
`;

exports[`Table.Expand renders tree row correctly with different children 1`] = `
<div
class="rc-table"
>
<div
class="rc-table-container"
>
<div
class="rc-table-content"
>
<table
style="table-layout: auto;"
>
<colgroup>
<col />
<col />
</colgroup>
<thead>
<tr>
<th
class="rc-table-cell"
>
Name
</th>
<th
class="rc-table-cell"
>
Age
</th>
</tr>
</thead>
<tbody
class="rc-table-tbody"
>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
Lucy
</td>
<td
class="rc-table-cell"
>
27
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-spaced"
/>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-spaced"
/>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-spaced"
/>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
>
<td
class="rc-table-cell rc-table-cell-with-append"
>
<span
class="rc-table-row-indent indent-level-0"
/>
<span
class="rc-table-row-expand-icon rc-table-row-spaced"
/>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
`;

0 comments on commit c67130b

Please sign in to comment.