Skip to content

Commit 957f4ff

Browse files
authored
Update table-sort.spec.js
1 parent 7f2a9d4 commit 957f4ff

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/components/table/table-sort.spec.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import Table from './table'
22
import { mount } from '@vue/test-utils'
33

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' }]
95
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 }
139
]
1410

1511
describe('table sorting', () => {
@@ -33,12 +29,29 @@ describe('table sorting', () => {
3329
await wrapper.$nextTick()
3430
expect(wrapper.emitted('input')).toBeDefined()
3531
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)
3834
const $rows = wrapper.findAll('tbody > tr')
3935
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')
4356
})
4457
})

0 commit comments

Comments
 (0)