1
1
import { mount } from '@vue/test-utils' ;
2
+ import { mockDelay } from '@test/utils' ;
3
+ import { afterEach } from 'vitest' ;
2
4
import {
3
5
Table , BaseTable , PrimaryTable , EnhancedTable ,
4
6
} from '@/src/table/index.ts' ;
5
- import { mockDelay } from '@test/utils' ;
6
- import { afterEach } from 'vitest' ;
7
7
8
8
// 4 类表格组件同时测试
9
9
const TABLES = [ Table , BaseTable , PrimaryTable , EnhancedTable ] ;
@@ -24,7 +24,7 @@ const SIMPLE_COLUMNS = [
24
24
{ title : 'Instance' , colKey : 'instance' } ,
25
25
] ;
26
26
27
- function getTableMount ( ) {
27
+ function getTableMount ( TTable ) {
28
28
return mount ( {
29
29
data ( ) {
30
30
return {
@@ -42,7 +42,7 @@ function getTableMount() {
42
42
} ,
43
43
goToNextPage ( ) {
44
44
const { current, total, pageSize } = this . pagination ;
45
- this . pagination . current = Math . min ( current + 1 , Math . ceil ( total / pageSize ) ) ;
45
+ this . pagination . current = Math . min ( current + 1 , Math . ceil ( total / pageSize ) ) ;
46
46
} ,
47
47
onPaginationChange ( pageInfo ) {
48
48
this . pagination . current = pageInfo . current ;
@@ -53,8 +53,12 @@ function getTableMount() {
53
53
render ( ) {
54
54
return (
55
55
< div >
56
- < button class = 'prev-page' onClick = { this . goToPrevPage } > PrevPage</ button >
57
- < button class = 'next-page' onClick = { this . goToNextPage } > NextPage</ button >
56
+ < button class = "prev-page" onClick = { this . goToPrevPage } >
57
+ PrevPage
58
+ </ button >
59
+ < button class = "next-page" onClick = { this . goToNextPage } >
60
+ NextPage
61
+ </ button >
58
62
< TTable
59
63
rowKey = "id"
60
64
data = { this . data }
@@ -79,7 +83,7 @@ TABLES.forEach((TTable) => {
79
83
} ) ;
80
84
81
85
it ( 'controlled mode' , async ( ) => {
82
- const wrapper = getTableMount ( ) ;
86
+ const wrapper = getTableMount ( TTable ) ;
83
87
84
88
const firstSerialNumberClass = '.t-table tbody tr td:first-child' ;
85
89
expect ( wrapper . find ( '.t-table__pagination' ) . exists ( ) ) . toBeTruthy ( ) ;
0 commit comments