Skip to content

Commit

Permalink
test(comp:table): add test case and update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Nov 16, 2022
1 parent 170aa82 commit ba8bd04
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`Table > basic work > render work 1`] = `
"<div class=\\"ix-table ix-table-borderless ix-table-md\\">
<!---->
<!---->
<div class=\\"ix-table-container\\">
<div class=\\"ix-table-content\\">
Expand Down Expand Up @@ -312,7 +311,6 @@ exports[`Table > basic work > render work 1`] = `
</table>
</div>
</div>
<!---->
<ul class=\\"ix-pagination ix-pagination-md ix-table-pagination ix-table-pagination-end\\" position=\\"bottomEnd\\">
<li class=\\"ix-pagination-total\\">共 100 项</li>
<li class=\\"ix-pagination-item ix-pagination-item-prev ix-pagination-item-disabled\\" tabindex=\\"-1\\" title=\\"上一页\\"><span class=\\"ix-pagination-item-content\\"><i class=\\"ix-icon ix-icon-left\\" role=\\"img\\" aria-label=\\"left\\"></i></span></li>
Expand Down
16 changes: 16 additions & 0 deletions packages/components/table/__tests__/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ describe('Table', () => {
expect(wrapper.find('tbody').findAll('td')[2].attributes('title')).not.toBe(undefined)
})

test('ellipsis with head work', async () => {
const wrapper = TableMount({ props: { ellipsis: { head: false } } })

expect(wrapper.find('thead').findAll('th')[2].classes()).not.toContain('ix-table-cell-ellipsis')
expect(wrapper.find('tbody').findAll('td')[2].classes()).toContain('ix-table-cell-ellipsis')
expect(wrapper.find('thead').findAll('th')[2].attributes('title')).toBe(undefined)
expect(wrapper.find('tbody').findAll('td')[2].attributes('title')).not.toBe(undefined)

await wrapper.setProps({ ellipsis: { head: true } })

expect(wrapper.find('thead').findAll('th')[2].classes()).toContain('ix-table-cell-ellipsis')
expect(wrapper.find('tbody').findAll('td')[2].classes()).toContain('ix-table-cell-ellipsis')
expect(wrapper.find('thead').findAll('th')[2].attributes('title')).not.toBe(undefined)
expect(wrapper.find('tbody').findAll('td')[2].attributes('title')).not.toBe(undefined)
})

test('ellipsis with columns work', async () => {
const wrapper = TableMount({
props: {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/table/src/main/body/BodyCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function renderExpandableChildren(
} else {
iconNode = isFunction(icon) ? icon({ expanded, record }) : icon
if (isString(iconNode)) {
iconNode = <IxIcon name={iconNode} />
iconNode = <IxIcon name={iconNode} rotate={expanded ? 90 : 0} />
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/components/table/src/main/head/HeadCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default defineComponent({
// tableProps 的 ellipsis 对特殊(带有 type )的列不生效
const { type, ellipsis } = props.column as HeadColumn
const _ellipsis = type ? ellipsis : ellipsis ?? tableProps.ellipsis
return isObject(_ellipsis) && !_ellipsis.head ? undefined : _ellipsis
return isObject(_ellipsis) && _ellipsis.head === false ? undefined : _ellipsis
})

const classes = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/table/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getColTitle(
children: VNodeChild,
title: string | undefined,
): string | undefined {
if (!ellipsis || (isObject(ellipsis) && !ellipsis.title)) {
if (!ellipsis || (isObject(ellipsis) && ellipsis.title === false)) {
return undefined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ exports[`ProTransfer > table transfer render work 1`] = `
class="ix-table ix-table-auto-height ix-table-borderless ix-table-md ix-pro-transfer-table-content"
>
<!---->
<!---->
<div
class="ix-table-container ix-table-fixed-layout ix-table-scroll-vertical"
Expand Down Expand Up @@ -1001,8 +1000,6 @@ exports[`ProTransfer > table transfer render work 1`] = `
</div>
</div>
<!---->
<!---->
</div>
Expand Down Expand Up @@ -1092,7 +1089,6 @@ exports[`ProTransfer > table transfer render work 1`] = `
class="ix-table ix-table-auto-height ix-table-borderless ix-table-md ix-pro-transfer-table-content"
>
<!---->
<!---->
<div
class="ix-table-container ix-table-fixed-layout ix-table-scroll-vertical"
Expand Down Expand Up @@ -1370,8 +1366,6 @@ exports[`ProTransfer > table transfer render work 1`] = `
</div>
</div>
<!---->
<!---->
</div>
Expand Down

0 comments on commit ba8bd04

Please sign in to comment.