SvgIcon.spec.js 621 B

1234567891011121314151617181920212223
  1. import { shallowMount } from '@vue/test-utils'
  2. import SvgIcon from '@/components/SvgIcon/index.vue'
  3. describe('SvgIcon.vue', () => {
  4. it('iconClass', () => {
  5. const wrapper = shallowMount(SvgIcon, {
  6. propsData: {
  7. iconClass: 'test'
  8. }
  9. })
  10. expect(wrapper.find('use').attributes().href).toBe('#icon-test')
  11. })
  12. it('className', () => {
  13. const wrapper = shallowMount(SvgIcon, {
  14. propsData: {
  15. iconClass: 'test'
  16. }
  17. })
  18. expect(wrapper.classes().length).toBe(1)
  19. wrapper.setProps({ className: 'test' })
  20. expect(wrapper.classes().includes('test')).toBe(true)
  21. })
  22. })