pablocattaneo
2/5/2019 - 5:35 PM

How to mock a global componente?

//  Using stubs

import { shallowMount } from '@vue/test-utils'
import LmPagination from '@/components/LmPagination.vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

describe('LmPagination', () => {
  const wrapper = shallowMount(LmPagination, {
    propsData: {
      allRegistries: 300,
      maxAmountItemsShowsPerPaginationInTable: 10
    },
    mocks: {
      $t: (msg) => msg
    },
    stubs: {
      'font-awesome-icon': FontAwesomeIcon
    }
  })
  test('is a Vue instance', () => {
    expect(wrapper.isVueInstance()).toBeTruthy()
  })
  it('has a li', () => {
    expect(wrapper.contains('li')).toBe(true)
  })
})