empty.test.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, test } from 'vitest'
  3. import Empty from '../src/empty.vue'
  4. const AXIOM = 'Rem is the best girl'
  5. describe('Empty.vue', () => {
  6. test('render test', () => {
  7. const wrapper = mount(() => <Empty>{AXIOM}</Empty>)
  8. expect(wrapper.find('.el-empty__image').exists()).toBe(true)
  9. expect(wrapper.find('.el-empty__description').exists()).toBe(true)
  10. expect(wrapper.find('.el-empty__bottom').exists()).toBe(true)
  11. })
  12. test('should render image props', () => {
  13. const wrapper = mount(() => <Empty image={AXIOM} />)
  14. expect(wrapper.find('.el-empty__image img').exists()).toBe(true)
  15. })
  16. test('should render imageSize props', async () => {
  17. const wrapper = mount(() => <Empty imageSize={500} />)
  18. expect(wrapper.find('.el-empty__image').attributes('style')).toContain(
  19. 'width: 500px'
  20. )
  21. })
  22. test('should render description props', () => {
  23. const wrapper = mount(() => <Empty description={AXIOM} />)
  24. expect(wrapper.find('.el-empty__description').text()).toEqual(AXIOM)
  25. })
  26. test('should render image slots', () => {
  27. const wrapper = mount(() => (
  28. <Empty
  29. v-slots={{
  30. image: () => AXIOM,
  31. }}
  32. />
  33. ))
  34. expect(wrapper.find('.el-empty__image').text()).toEqual(AXIOM)
  35. })
  36. test('should render description slots', () => {
  37. const wrapper = mount(() => (
  38. <Empty
  39. v-slots={{
  40. description: () => AXIOM,
  41. }}
  42. />
  43. ))
  44. expect(wrapper.find('.el-empty__description').text()).toEqual(AXIOM)
  45. })
  46. test('should render default slots', async () => {
  47. const wrapper = mount(() => (
  48. <Empty
  49. v-slots={{
  50. default: () => AXIOM,
  51. }}
  52. />
  53. ))
  54. expect(wrapper.find('.el-empty__bottom').text()).toEqual(AXIOM)
  55. })
  56. })