d2-page-cover.spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { mount } from '@vue/test-utils'
  2. import D2PageCover from '@/components/d2-page-cover/index.vue'
  3. describe('d2-page-cover', () => {
  4. // 存在且是Vue组件实例
  5. it('is a vue instance', () => {
  6. const wrapper = mount(D2PageCover)
  7. expect(wrapper.exists()).toBeTruthy()
  8. expect(wrapper.isVueInstance()).toBeTruthy()
  9. })
  10. // 包含特定类名
  11. it('contains specific classnames', () => {
  12. const wrapper = mount(D2PageCover, {
  13. slots: {
  14. default: '<div>default</div>',
  15. footer: '<div>footer</div>'
  16. }
  17. })
  18. expect(wrapper.is('.d2-page-cover')).toBeTruthy()
  19. expect(wrapper.contains('.d2-page-cover__logo')).toBeTruthy()
  20. expect(wrapper.contains('.d2-page-cover__title')).toBeTruthy()
  21. expect(wrapper.contains('.d2-page-cover__sub-title')).toBeTruthy()
  22. expect(wrapper.contains('.d2-page-cover__build-time')).toBeTruthy()
  23. })
  24. // 渲染slot
  25. it('has one or more slots', () => {
  26. const wrapper = mount(D2PageCover, {
  27. slots: {
  28. default: '<div>default</div>',
  29. footer: '<div>footer</div>'
  30. }
  31. })
  32. expect(wrapper.text()).toMatch('default')
  33. expect(wrapper.text()).toMatch('footer')
  34. })
  35. })