ibps-container-ghost-bs.spec.js 1.8 KB

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