2020-07-28 13:59:53 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
2022-04-19 12:46:57 +08:00
|
|
|
import { describe, expect, test } from 'vitest'
|
2021-09-19 15:50:11 +08:00
|
|
|
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', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
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', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
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', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
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', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
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
|
|
|
})
|
2021-12-09 20:41:38 +08:00
|
|
|
|
|
|
|
test('line-dashed', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
const wrapper = mount(() => <Divider borderStyle="dashed" />)
|
2021-12-09 20:41:38 +08:00
|
|
|
expect(
|
|
|
|
getComputedStyle(wrapper.element, null).getPropertyValue(
|
|
|
|
'--el-border-style'
|
|
|
|
)
|
|
|
|
).toBe('dashed')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('line-solid', () => {
|
2022-06-14 18:02:41 +08:00
|
|
|
const wrapper = mount(() => <Divider direction="vertical" />)
|
2021-12-09 20:41:38 +08:00
|
|
|
expect(
|
|
|
|
getComputedStyle(wrapper.element, null).getPropertyValue(
|
|
|
|
'--el-border-style'
|
|
|
|
)
|
|
|
|
).toBe('solid')
|
|
|
|
})
|
2020-07-27 23:22:31 +08:00
|
|
|
})
|