liweilong
2020-12-09 efd7c8fea38ab641db8581fb8c9d910640cfc8fb
提交 | 用户 | age
2a61f6 1 import { shallowMount } from '@vue/test-utils'
L 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 })