Hamburger.spec.js 641 B

123456789101112131415161718
  1. import { shallowMount } from '@vue/test-utils'
  2. import Hamburger from '@/components/Hamburger/index.vue'
  3. describe('Hamburger.vue', () => {
  4. it('toggle click', () => {
  5. const wrapper = shallowMount(Hamburger)
  6. const mockFn = jest.fn()
  7. wrapper.vm.$on('toggleClick', mockFn)
  8. wrapper.find('.hamburger').trigger('click')
  9. expect(mockFn).toBeCalled()
  10. })
  11. it('prop isActive', () => {
  12. const wrapper = shallowMount(Hamburger)
  13. wrapper.setProps({ isActive: true })
  14. expect(wrapper.contains('.is-active')).toBe(true)
  15. wrapper.setProps({ isActive: false })
  16. expect(wrapper.contains('.is-active')).toBe(false)
  17. })
  18. })