element-plus/packages/components/divider/__tests__/divider.test.ts

73 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-07-28 13:59:53 +08:00
import { mount } from '@vue/test-utils'
import { describe, expect, test } from 'vitest'
import Divider from '../src/divider.vue'
2020-07-27 23:22:31 +08:00
const AXIOM = 'Rem is the best girl'
describe('Divider.vue', () => {
test('render test', () => {
const wrapper = mount(Divider, {
slots: {
default: AXIOM,
},
})
2020-07-28 13:59:53 +08:00
expect(wrapper.text()).toBe(AXIOM)
2020-07-27 23:22:31 +08:00
})
test('direction', () => {
2020-07-28 13:59:53 +08:00
const wrapper = mount(Divider, {
2020-07-27 23:22:31 +08:00
props: {
direction: 'vertical',
},
})
2020-07-28 13:59:53 +08:00
expect(wrapper.classes()).toContain('el-divider--vertical')
2020-07-27 23:22:31 +08:00
})
test('contentPosition', () => {
const wrapper = mount(Divider, {
slots: {
default: AXIOM,
},
props: {
contentPosition: 'right',
},
})
2020-07-28 13:59:53 +08:00
expect(wrapper.find('.el-divider__text').classes()).toContain('is-right')
2020-07-27 23:22:31 +08:00
})
test('customClass', () => {
2020-07-28 13:59:53 +08:00
const wrapper = mount(Divider, {
2020-07-27 23:22:31 +08:00
props: {
class: 'customClass',
},
})
2020-07-28 13:59:53 +08:00
expect(wrapper.classes()).toContain('customClass')
2020-07-27 23:22:31 +08:00
})
test('line-dashed', () => {
const wrapper = mount(Divider, {
props: {
borderStyle: 'dashed',
},
})
expect(
getComputedStyle(wrapper.element, null).getPropertyValue(
'--el-border-style'
)
).toBe('dashed')
})
test('line-solid', () => {
const wrapper = mount(Divider, {
props: {
direction: 'vertical',
},
})
expect(
getComputedStyle(wrapper.element, null).getPropertyValue(
'--el-border-style'
)
).toBe('solid')
})
2020-07-27 23:22:31 +08:00
})