From 987c3872bf6a1b7a96fd90bb2da5f84271cc19b0 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sat, 7 Aug 2021 00:00:02 +0800 Subject: [PATCH] test: update table snap --- .../__snapshots__/index.test.js.snap | 510 +++++++----------- .../Table.pagination.test.js.snap | 6 +- .../Table.rowSelection.test.js.snap | 70 +-- .../__snapshots__/Table.sorter.test.js.snap | 2 +- .../__snapshots__/Table.test.js.snap | 26 +- .../__snapshots__/empty.test.js.snap | 193 +++---- components/vc-table/src/Table.jsx | 3 +- components/vc-table/src/useColumnManager.jsx | 18 +- 8 files changed, 309 insertions(+), 519 deletions(-) diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index a1acebd63..a241d4367 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -1072,16 +1072,16 @@ exports[`Locale Provider should display the text as ar 1`] = `
- - + + - - @@ -1106,8 +1106,6 @@ exports[`Locale Provider should display the text as ar 1`] = ` - - @@ -1614,16 +1612,16 @@ exports[`Locale Provider should display the text as bg 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -1648,8 +1646,6 @@ exports[`Locale Provider should display the text as bg 1`] = ` - - @@ -2156,16 +2152,16 @@ exports[`Locale Provider should display the text as ca 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -2190,8 +2186,6 @@ exports[`Locale Provider should display the text as ca 1`] = ` - - @@ -2698,16 +2692,16 @@ exports[`Locale Provider should display the text as cs 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -2732,8 +2726,6 @@ exports[`Locale Provider should display the text as cs 1`] = ` - - @@ -3240,16 +3232,16 @@ exports[`Locale Provider should display the text as da 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -3274,8 +3266,6 @@ exports[`Locale Provider should display the text as da 1`] = ` - - @@ -3782,16 +3772,16 @@ exports[`Locale Provider should display the text as de 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -3816,8 +3806,6 @@ exports[`Locale Provider should display the text as de 1`] = ` - - @@ -4324,16 +4312,16 @@ exports[`Locale Provider should display the text as el 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -4358,8 +4346,6 @@ exports[`Locale Provider should display the text as el 1`] = ` - - @@ -4866,16 +4852,16 @@ exports[`Locale Provider should display the text as en 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -4900,8 +4886,6 @@ exports[`Locale Provider should display the text as en 1`] = ` - - @@ -5408,16 +5392,16 @@ exports[`Locale Provider should display the text as en-gb 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -5442,8 +5426,6 @@ exports[`Locale Provider should display the text as en-gb 1`] = ` - - @@ -5950,16 +5932,16 @@ exports[`Locale Provider should display the text as es 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -5984,8 +5966,6 @@ exports[`Locale Provider should display the text as es 1`] = ` - - @@ -6492,16 +6472,16 @@ exports[`Locale Provider should display the text as et 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -6526,8 +6506,6 @@ exports[`Locale Provider should display the text as et 1`] = ` - - @@ -7034,16 +7012,16 @@ exports[`Locale Provider should display the text as fa 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -7068,8 +7046,6 @@ exports[`Locale Provider should display the text as fa 1`] = ` - - @@ -7576,16 +7552,16 @@ exports[`Locale Provider should display the text as fi 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -7610,8 +7586,6 @@ exports[`Locale Provider should display the text as fi 1`] = ` - - @@ -8118,16 +8092,16 @@ exports[`Locale Provider should display the text as fr 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -8152,8 +8126,6 @@ exports[`Locale Provider should display the text as fr 1`] = ` - - @@ -8660,16 +8632,16 @@ exports[`Locale Provider should display the text as fr 2`] = `
Name +
Name
Age +
Age
- - + + - - @@ -8694,8 +8666,6 @@ exports[`Locale Provider should display the text as fr 2`] = ` - - @@ -9202,16 +9172,16 @@ exports[`Locale Provider should display the text as he 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -9236,8 +9206,6 @@ exports[`Locale Provider should display the text as he 1`] = ` - - @@ -9744,16 +9712,16 @@ exports[`Locale Provider should display the text as hi 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -9778,8 +9746,6 @@ exports[`Locale Provider should display the text as hi 1`] = ` - - @@ -10286,16 +10252,16 @@ exports[`Locale Provider should display the text as hr 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -10320,8 +10286,6 @@ exports[`Locale Provider should display the text as hr 1`] = ` - - @@ -10828,16 +10792,16 @@ exports[`Locale Provider should display the text as hu 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -10862,8 +10826,6 @@ exports[`Locale Provider should display the text as hu 1`] = ` - - @@ -11370,16 +11332,16 @@ exports[`Locale Provider should display the text as hy 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -11404,8 +11366,6 @@ exports[`Locale Provider should display the text as hy 1`] = ` - - @@ -11912,16 +11872,16 @@ exports[`Locale Provider should display the text as id 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -11946,8 +11906,6 @@ exports[`Locale Provider should display the text as id 1`] = ` - - @@ -12454,16 +12412,16 @@ exports[`Locale Provider should display the text as is 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -12488,8 +12446,6 @@ exports[`Locale Provider should display the text as is 1`] = ` - - @@ -12996,16 +12952,16 @@ exports[`Locale Provider should display the text as it 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -13030,8 +12986,6 @@ exports[`Locale Provider should display the text as it 1`] = ` - - @@ -13538,16 +13492,16 @@ exports[`Locale Provider should display the text as ja 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -13572,8 +13526,6 @@ exports[`Locale Provider should display the text as ja 1`] = ` - - @@ -14080,16 +14032,16 @@ exports[`Locale Provider should display the text as kn 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -14114,8 +14066,6 @@ exports[`Locale Provider should display the text as kn 1`] = ` - - @@ -14622,16 +14572,16 @@ exports[`Locale Provider should display the text as ko 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -14656,8 +14606,6 @@ exports[`Locale Provider should display the text as ko 1`] = ` - - @@ -15164,16 +15112,16 @@ exports[`Locale Provider should display the text as ku-iq 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -15198,8 +15146,6 @@ exports[`Locale Provider should display the text as ku-iq 1`] = ` - - @@ -15706,16 +15652,16 @@ exports[`Locale Provider should display the text as lv 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -15740,8 +15686,6 @@ exports[`Locale Provider should display the text as lv 1`] = ` - - @@ -16248,16 +16192,16 @@ exports[`Locale Provider should display the text as mk 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -16282,8 +16226,6 @@ exports[`Locale Provider should display the text as mk 1`] = ` - - @@ -16790,16 +16732,16 @@ exports[`Locale Provider should display the text as mn-mn 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -16824,8 +16766,6 @@ exports[`Locale Provider should display the text as mn-mn 1`] = ` - - @@ -17332,16 +17272,16 @@ exports[`Locale Provider should display the text as ms-my 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -17366,8 +17306,6 @@ exports[`Locale Provider should display the text as ms-my 1`] = ` - - @@ -17874,16 +17812,16 @@ exports[`Locale Provider should display the text as nb 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -17908,8 +17846,6 @@ exports[`Locale Provider should display the text as nb 1`] = ` - - @@ -18416,16 +18352,16 @@ exports[`Locale Provider should display the text as ne-np 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -18450,8 +18386,6 @@ exports[`Locale Provider should display the text as ne-np 1`] = ` - - @@ -18958,16 +18892,16 @@ exports[`Locale Provider should display the text as nl 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -18992,8 +18926,6 @@ exports[`Locale Provider should display the text as nl 1`] = ` - - @@ -19500,16 +19432,16 @@ exports[`Locale Provider should display the text as nl-be 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -19534,8 +19466,6 @@ exports[`Locale Provider should display the text as nl-be 1`] = ` - - @@ -20042,16 +19972,16 @@ exports[`Locale Provider should display the text as pl 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -20076,8 +20006,6 @@ exports[`Locale Provider should display the text as pl 1`] = ` - - @@ -20584,16 +20512,16 @@ exports[`Locale Provider should display the text as pt 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -20618,8 +20546,6 @@ exports[`Locale Provider should display the text as pt 1`] = ` - - @@ -21126,16 +21052,16 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -21160,8 +21086,6 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - - @@ -21668,16 +21592,16 @@ exports[`Locale Provider should display the text as ro 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -21702,8 +21626,6 @@ exports[`Locale Provider should display the text as ro 1`] = ` - - @@ -22210,16 +22132,16 @@ exports[`Locale Provider should display the text as ru 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -22244,8 +22166,6 @@ exports[`Locale Provider should display the text as ru 1`] = ` - - @@ -22752,16 +22672,16 @@ exports[`Locale Provider should display the text as sk 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -22786,8 +22706,6 @@ exports[`Locale Provider should display the text as sk 1`] = ` - - @@ -23294,16 +23212,16 @@ exports[`Locale Provider should display the text as sl 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -23328,8 +23246,6 @@ exports[`Locale Provider should display the text as sl 1`] = ` - - @@ -23836,16 +23752,16 @@ exports[`Locale Provider should display the text as sr 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -23870,8 +23786,6 @@ exports[`Locale Provider should display the text as sr 1`] = ` - - @@ -24378,16 +24292,16 @@ exports[`Locale Provider should display the text as sv 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -24412,8 +24326,6 @@ exports[`Locale Provider should display the text as sv 1`] = ` - - @@ -24920,16 +24832,16 @@ exports[`Locale Provider should display the text as ta 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -24954,8 +24866,6 @@ exports[`Locale Provider should display the text as ta 1`] = ` - - @@ -25462,16 +25372,16 @@ exports[`Locale Provider should display the text as th 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -25496,8 +25406,6 @@ exports[`Locale Provider should display the text as th 1`] = ` - - @@ -26004,16 +25912,16 @@ exports[`Locale Provider should display the text as tr 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -26038,8 +25946,6 @@ exports[`Locale Provider should display the text as tr 1`] = ` - - @@ -26546,16 +26452,16 @@ exports[`Locale Provider should display the text as uk 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -26580,8 +26486,6 @@ exports[`Locale Provider should display the text as uk 1`] = ` - - @@ -27088,16 +26992,16 @@ exports[`Locale Provider should display the text as vi 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -27122,8 +27026,6 @@ exports[`Locale Provider should display the text as vi 1`] = ` - - @@ -27630,16 +27532,16 @@ exports[`Locale Provider should display the text as zh-cn 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -27664,8 +27566,6 @@ exports[`Locale Provider should display the text as zh-cn 1`] = ` - - @@ -28172,16 +28072,16 @@ exports[`Locale Provider should display the text as zh-tw 1`] = `
Name +
Name
Age +
Age
- - + + - - @@ -28206,8 +28106,6 @@ exports[`Locale Provider should display the text as zh-tw 1`] = ` - - diff --git a/components/table/__tests__/__snapshots__/Table.pagination.test.js.snap b/components/table/__tests__/__snapshots__/Table.pagination.test.js.snap index 50f0b167b..13207221e 100644 --- a/components/table/__tests__/__snapshots__/Table.pagination.test.js.snap +++ b/components/table/__tests__/__snapshots__/Table.pagination.test.js.snap @@ -12,11 +12,11 @@ exports[`Table.pagination renders pagination correctly 1`] = `
Name +
Name
Age +
Age
- + - @@ -40,8 +40,6 @@ exports[`Table.pagination renders pagination correctly 1`] = ` - -
Name +
Name
- - + + - - @@ -33,7 +33,7 @@ exports[`Table.rowSelection fix selection column on the left 1`] = ` - - - - - diff --git a/components/table/__tests__/__snapshots__/Table.test.js.snap b/components/table/__tests__/__snapshots__/Table.test.js.snap index d0fe98a73..41619b838 100644 --- a/components/table/__tests__/__snapshots__/Table.test.js.snap +++ b/components/table/__tests__/__snapshots__/Table.test.js.snap @@ -12,16 +12,16 @@ exports[`Table align column should not override cell style 1`] = `
Name +
Name
+ @@ -44,7 +44,7 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
+ @@ -55,7 +55,7 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
+ @@ -66,7 +66,7 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
+ @@ -82,62 +82,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = ` -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
- - -
- - -
- - -
- - -
-
- - -
  • diff --git a/components/table/__tests__/__snapshots__/Table.sorter.test.js.snap b/components/table/__tests__/__snapshots__/Table.sorter.test.js.snap index 9a9afac87..5ac4cad16 100644 --- a/components/table/__tests__/__snapshots__/Table.sorter.test.js.snap +++ b/components/table/__tests__/__snapshots__/Table.sorter.test.js.snap @@ -3,7 +3,7 @@ exports[`Table.sorter renders sorter icon correctly 1`] = `
Name
+
Name
- - + + - - @@ -55,8 +55,6 @@ exports[`Table align column should not override cell style 1`] = ` - -
Name +
Name
Age +
Age
- - - + + + - - - - @@ -143,8 +141,6 @@ exports[`Table renders JSX correctly 1`] = ` - - diff --git a/components/table/__tests__/__snapshots__/empty.test.js.snap b/components/table/__tests__/__snapshots__/empty.test.js.snap index b32cee615..639c4a0ea 100644 --- a/components/table/__tests__/__snapshots__/empty.test.js.snap +++ b/components/table/__tests__/__snapshots__/empty.test.js.snap @@ -12,45 +12,45 @@ exports[`Table renders empty table 1`] = `
Name +
Name
Age +
Age
First Name +
First Name
Last Name +
Last Name
- - - - - - - - + + + + + + + + - - - - - - - - @@ -74,8 +74,6 @@ exports[`Table renders empty table 1`] = ` - - @@ -95,45 +93,45 @@ exports[`Table renders empty table with custom emptyText 1`] = `
Column 1 +
Column 1
Column 2 +
Column 2
Column 3 +
Column 3
Column 4 +
Column 4
Column 5 +
Column 5
Column 6 +
Column 6
Column 7
+
Column 7
Column 8
+
Column 8
- - - - - - - - + + + + + + + + - - - - - - - - @@ -143,8 +141,6 @@ exports[`Table renders empty table with custom emptyText 1`] = `
custom empty text
- - @@ -165,58 +161,58 @@ exports[`Table renders empty table with fixed columns 1`] = `
Column 1 +
Column 1
Column 2 +
Column 2
Column 3 +
Column 3
Column 4 +
Column 4
Column 5 +
Column 5
Column 6 +
Column 6
Column 7
+
Column 7
Column 8
+
Column 8
- - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - @@ -241,53 +237,6 @@ exports[`Table renders empty table with fixed columns 1`] = ` -
- -
-
-
Full Name +
Full Name
Age +
Age
Column 1 +
Column 1
Column 2 +
Column 2
Column 3 +
Column 3
Column 4 +
Column 4
Column 5 +
Column 5
Column 6
+
Column 6
Column 7
+
Column 7
Column 8
+
Column 8
Action
+
Action
- - - - - - - - - - - -
Full Name -
- -
Age -
- -
-
- - -
- -
-
- - - - - - - - - - -
Action -
- -
-
-
-
@@ -311,45 +260,45 @@ exports[`Table renders empty table without emptyText when loading 1`] = `
- - - - - - - - + + + + + + + + - - - - - - - - @@ -373,8 +322,6 @@ exports[`Table renders empty table without emptyText when loading 1`] = ` - - diff --git a/components/vc-table/src/Table.jsx b/components/vc-table/src/Table.jsx index 4d1cdd591..c05c4a379 100644 --- a/components/vc-table/src/Table.jsx +++ b/components/vc-table/src/Table.jsx @@ -9,6 +9,7 @@ import { ref, onUpdated, onMounted, + toRef, } from 'vue'; import shallowequal from '../../_util/shallowequal'; import merge from 'lodash-es/merge'; @@ -99,7 +100,7 @@ export default defineComponent({ }, ), setup(props) { - const columnManager = useColumnManager(props.columns); + const columnManager = useColumnManager(toRef(props, 'columns')); const colsKeys = computed(() => getColumnsKey(columnManager.leafColumns.value)); const [colsWidths, updateColsWidths] = useLayoutState(new Map()); const pureColWidths = computed(() => diff --git a/components/vc-table/src/useColumnManager.jsx b/components/vc-table/src/useColumnManager.jsx index d8cfb22f5..11c89c63b 100644 --- a/components/vc-table/src/useColumnManager.jsx +++ b/components/vc-table/src/useColumnManager.jsx @@ -23,7 +23,7 @@ export default function useColumnManager(columns) { const rowSpan = rows.length - currentRow; if ( column && - !column.children && // parent columns are supposed to be one row + !column.children && // parent columns.value are supposed to be one row rowSpan > 1 && (!column.rowSpan || column.rowSpan < rowSpan) ) { @@ -47,7 +47,7 @@ export default function useColumnManager(columns) { } else { parentColumn.colSpan += 1; } - // update rowspan to all same row columns + // update rowspan to all same row columns.value for (let i = 0; i < rows[currentRow].length - 1; i += 1) { setRowSpan(rows[currentRow][i]); } @@ -59,16 +59,18 @@ export default function useColumnManager(columns) { }); return grouped; }; - return _groupColumns(columns); + return _groupColumns(columns.value); }); - const isAnyColumnsFixed = computed(() => columns.some(column => !!column.fixed)); + const isAnyColumnsFixed = computed(() => columns.value.some(column => !!column.fixed)); const isAnyColumnsLeftFixed = computed(() => - columns.some(column => column.fixed === 'left' || column.fixed === true), + columns.value.some(column => column.fixed === 'left' || column.fixed === true), ); - const isAnyColumnsRightFixed = computed(() => columns.some(column => column.fixed === 'right')); + const isAnyColumnsRightFixed = computed(() => + columns.value.some(column => column.fixed === 'right'), + ); const leftColumns = computed(() => groupedColumns.value.filter(column => column.fixed === 'left' || column.fixed === true), @@ -78,7 +80,9 @@ export default function useColumnManager(columns) { return groupedColumns.value.filter(column => column.fixed === 'right'); }); - const leafColumns = computed(() => _leafColumns(columns)); + const leafColumns = computed(() => { + return _leafColumns(columns.value); + }); const leftLeafColumns = computed(() => _leafColumns(leftColumns.value));
Column 1 +
Column 1
Column 2 +
Column 2
Column 3 +
Column 3
Column 4 +
Column 4
Column 5 +
Column 5
Column 6 +
Column 6
Column 7
+
Column 7
Column 8
+
Column 8