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

59 lines
1.4 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
v-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', () => {
const wrapper = mount(() => <Divider 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
v-slots={{
default: () => AXIOM,
}}
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', () => {
const wrapper = mount(() => <Divider 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 borderStyle="dashed" />)
expect(
getComputedStyle(wrapper.element, null).getPropertyValue(
'--el-border-style'
)
).toBe('dashed')
})
test('line-solid', () => {
const wrapper = mount(() => <Divider direction="vertical" />)
expect(
getComputedStyle(wrapper.element, null).getPropertyValue(
'--el-border-style'
)
).toBe('solid')
})
2020-07-27 23:22:31 +08:00
})