ibps-container-card.spec.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { mount } from '@vue/test-utils'
  2. import IbpsContainerCard from '@/components/ibps-container/components/ibps-container-card.vue'
  3. describe('ibps-container-card', () => {
  4. // 存在且是Vue组件实例
  5. it('is a vue instance', () => {
  6. const wrapper = mount(IbpsContainerCard)
  7. expect(wrapper.exists()).toBeTruthy()
  8. expect(wrapper.isVueInstance()).toBeTruthy()
  9. })
  10. // 包含特定类名
  11. it('contains specific classnames', () => {
  12. const wrapper = mount(IbpsContainerCard, {
  13. slots: {
  14. default: '<div>body</div>',
  15. header: '<div>header</div>',
  16. footer: '<div>footer</div>'
  17. }
  18. })
  19. expect(wrapper.is('.ibps-container-card')).toBeTruthy()
  20. expect(wrapper.contains('.ibps-container-card__header')).toBeTruthy()
  21. expect(wrapper.contains('.ibps-container-card__body')).toBeTruthy()
  22. expect(wrapper.contains('.ibps-container-card__body-card')).toBeTruthy()
  23. expect(wrapper.contains('.ibps-container-card__footer')).toBeTruthy()
  24. })
  25. // props
  26. it('has props', () => {
  27. const wrapper = mount(IbpsContainerCard, {
  28. propsData: {
  29. scrollDelay: 30
  30. }
  31. })
  32. expect(wrapper.props().scrollDelay).toEqual(30)
  33. })
  34. // 渲染slot
  35. it('has one or more slots', () => {
  36. const wrapper = mount(IbpsContainerCard, {
  37. slots: {
  38. default: '<div>body</div>',
  39. header: '<div>header</div>',
  40. footer: '<div>footer</div>'
  41. }
  42. })
  43. expect(wrapper.text()).toMatch('header')
  44. expect(wrapper.text()).toMatch('body')
  45. expect(wrapper.text()).toMatch('footer')
  46. })
  47. })