1
1
import Table from './table'
2
2
import { mount } from '@vue/test-utils'
3
3
4
- const testItems = [
5
- { a : 3 , b : 'b' , c : 'x' } ,
6
- { a : 1 , b : 'c' , c : 'y' } ,
7
- { a : 2 , b : 'a' , c : 'z' }
8
- ]
4
+ const testItems = [ { a : 3 , b : 'b' , c : 'x' } , { a : 1 , b : 'c' , c : 'y' } , { a : 2 , b : 'a' , c : 'z' } ]
9
5
const testFields = [
10
- { key : 'a' , label : 'A' , sortable : true } ,
11
- { key : 'b' , label : 'B' , sortable : true } ,
12
- { key : 'c' , label : 'C' , sortable : false }
6
+ { key : 'a' , label : 'A' , sortable : true } ,
7
+ { key : 'b' , label : 'B' , sortable : true } ,
8
+ { key : 'c' , label : 'C' , sortable : false }
13
9
]
14
10
15
11
describe ( 'table sorting' , ( ) => {
@@ -33,12 +29,29 @@ describe('table sorting', () => {
33
29
await wrapper . $nextTick ( )
34
30
expect ( wrapper . emitted ( 'input' ) ) . toBeDefined ( )
35
31
expect ( wrapper . emitted ( 'input' ) . lnegth ) . toBe ( 1 )
36
- expect ( wrapper . emitted ( 'input' ) [ 0 ] [ 0 ] ) . toEqual ( testRows )
37
- expect ( visibleRows ) . toEqual ( testRows )
32
+ expect ( wrapper . emitted ( 'input' ) [ 0 ] [ 0 ] ) . toEqual ( testItems )
33
+ expect ( visibleRows ) . toEqual ( testItems )
38
34
const $rows = wrapper . findAll ( 'tbody > tr' )
39
35
expect ( $rows . length ) . toBe ( 3 )
40
- expect ( $rows . at ( 0 ) . findAll ( 'td' ) . at ( 0 ) . text ( ) ) . toBe ( '3' )
41
- expect ( $rows . at ( 1 ) . findAll ( 'td' ) . at ( 0 ) . text ( ) ) . toBe ( '1' )
42
- expect ( $rows . at ( 2 ) . findAll ( 'td' ) . at ( 0 ) . text ( ) ) . toBe ( '2' )
36
+ expect (
37
+ $rows
38
+ . at ( 0 )
39
+ . findAll ( 'td' )
40
+ . at ( 0 )
41
+ . text ( )
42
+ ) . toBe ( '3' )
43
+ expect (
44
+ $rows
45
+ . at ( 1 )
46
+ . findAll ( 'td' )
47
+ . at ( 0 )
48
+ . text ( )
49
+ ) . toBe ( '1' )
50
+ expect (
51
+ $rows
52
+ . at ( 2 )
53
+ . findAll ( 'td' )
54
+ . at ( 0 ) . text ( )
55
+ ) . toBe ( '2' )
43
56
} )
44
57
} )
0 commit comments