ibps-container-full.spec.js 1.5 KB

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