divider.test.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, test } from 'vitest'
  3. import Divider from '../src/divider.vue'
  4. const AXIOM = 'Rem is the best girl'
  5. describe('Divider.vue', () => {
  6. test('render test', () => {
  7. const wrapper = mount(() => (
  8. <Divider
  9. v-slots={{
  10. default: () => AXIOM,
  11. }}
  12. />
  13. ))
  14. expect(wrapper.text()).toBe(AXIOM)
  15. })
  16. test('direction', () => {
  17. const wrapper = mount(() => <Divider direction="vertical" />)
  18. expect(wrapper.classes()).toContain('el-divider--vertical')
  19. })
  20. test('contentPosition', () => {
  21. const wrapper = mount(() => (
  22. <Divider
  23. v-slots={{
  24. default: () => AXIOM,
  25. }}
  26. contentPosition="right"
  27. />
  28. ))
  29. expect(wrapper.find('.el-divider__text').classes()).toContain('is-right')
  30. })
  31. test('customClass', () => {
  32. const wrapper = mount(() => <Divider class="customClass" />)
  33. expect(wrapper.classes()).toContain('customClass')
  34. })
  35. test('line-dashed', () => {
  36. const wrapper = mount(() => <Divider borderStyle="dashed" />)
  37. expect(
  38. getComputedStyle(wrapper.element, null).getPropertyValue(
  39. '--el-border-style'
  40. )
  41. ).toBe('dashed')
  42. })
  43. test('line-solid', () => {
  44. const wrapper = mount(() => <Divider direction="vertical" />)
  45. expect(
  46. getComputedStyle(wrapper.element, null).getPropertyValue(
  47. '--el-border-style'
  48. )
  49. ).toBe('solid')
  50. })
  51. })