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', () => {
|
|
|
|
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
|
|
|
})
|
2021-12-09 20:41:38 +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
|
|
|
})
|