ibps-container-full-bs.spec.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { mount } from '@vue/test-utils'
  2. import IbpsContainerFullBs from '@/components/ibps-container/components/ibps-container-full-bs.vue'
  3. describe('ibps-container-full-bs', () => {
  4. // 存在且是Vue组件实例
  5. it('is a vue instance', () => {
  6. const wrapper = mount(IbpsContainerFullBs)
  7. expect(wrapper.exists()).toBeTruthy()
  8. expect(wrapper.isVueInstance()).toBeTruthy()
  9. })
  10. // 包含特定类名
  11. it('contains specific classnames', () => {
  12. const wrapper = mount(IbpsContainerFullBs, {
  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-bs')).toBeTruthy()
  20. expect(wrapper.contains('.ibps-container-full-bs__header')).toBeTruthy()
  21. expect(wrapper.contains('.ibps-container-full-bs__body')).toBeTruthy()
  22. expect(wrapper.contains('.ibps-container-full-bs__body-wrapper-inner')).toBeTruthy()
  23. expect(wrapper.contains('.ibps-container-full-bs__footer')).toBeTruthy()
  24. })
  25. // props
  26. it('has props', () => {
  27. const wrapper = mount(IbpsContainerFullBs, {
  28. propsData: {
  29. betterScrollOptions: {}
  30. }
  31. })
  32. expect(wrapper.props().betterScrollOptions).toEqual({})
  33. })
  34. // 渲染slot
  35. it('has one or more slots', () => {
  36. const wrapper = mount(IbpsContainerFullBs, {
  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. })