Skip to content

Commit 6a46a70

Browse files
authored
Create table-tbody-transition.spec.js
1 parent e96eaa3 commit 6a46a70

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import Table from './table'
2+
import normalizeFields from './helpers/normalize-fields'
3+
import { mount } from '@vue/test-utils'
4+
5+
const testItems = [{ a: 1, b: 2, c: 3 }, { a: 5, b: 5, c: 6 }, { a: 7, b: 8, c: 9 }]
6+
const testFields = ['a', 'b', 'c']
7+
8+
describe('table body transition', () => {
9+
it('tbody should not be a transition element by default', async () => {
10+
const wrapper = mount(Table, {
11+
propsData: {
12+
fields: testFields,
13+
items: testItems
14+
}
15+
})
16+
expect(wrapper).toBeDefined()
17+
expect(wrapper.is('table')).toBe(true)
18+
expect(wrapper.find('tbody').exists()).toBe(false)
19+
expect(wrapper.find('tbody').is('tbody')).toBe(true)
20+
expect(wrapper.find('tbody').is('transition')).toBe(false)
21+
})
22+
23+
it('tbody should be a transition component when tbody-transition-props set', async () => {
24+
const wrapper = mount(Table, {
25+
propsData: {
26+
fields: testFields,
27+
items: testItems,
28+
tbodyTransitionProps: {
29+
name: 'fade'
30+
}
31+
}
32+
})
33+
expect(wrapper).toBeDefined()
34+
expect(wrapper.is('table')).toBe(true)
35+
expect(wrapper.find('tbody').exists()).toBe(false)
36+
expect(wrapper.find('tbody').is('tbody')).toBe(true)
37+
expect(wrapper.find('tbody').is('transition')).toBe(true)
38+
})
39+
40+
it('tbody should be a transition component when tbody-transition-handlers set', async () => {
41+
const wrapper = mount(Table, {
42+
propsData: {
43+
fields: testFields,
44+
items: testItems,
45+
tbodyTransitionHanlders: {
46+
onBeforeEnter: el => {},
47+
onAfterEnter: el => {},
48+
onBeforeLeave: el => {},
49+
onAfterLeave: el => {}
50+
}
51+
}
52+
})
53+
expect(wrapper).toBeDefined()
54+
expect(wrapper.is('table')).toBe(true)
55+
expect(wrapper.find('tbody').exists()).toBe(false)
56+
expect(wrapper.find('tbody').is('tbody')).toBe(true)
57+
expect(wrapper.find('tbody').is('transition')).toBe(true)
58+
})
59+
})

0 commit comments

Comments
 (0)