rt-sim-training-client/tests/unit/components/Hamburger.spec.js

20 lines
705 B
JavaScript
Raw Normal View History

2020-12-31 13:38:54 +08:00
import { shallowMount } from '@vue/test-utils';
import Hamburger from '@/components/Hamburger/index.vue';
2019-07-02 16:29:52 +08:00
describe('Hamburger.vue', () => {
2020-12-31 13:38:54 +08:00
it('toggle click', () => {
const wrapper = shallowMount(Hamburger);
const mockFn = jest.fn();
wrapper.vm.$on('toggleClick', mockFn);
wrapper.find('.hamburger').trigger('click');
expect(mockFn).toBeCalled();
});
it('prop isActive', () => {
const wrapper = shallowMount(Hamburger);
wrapper.setProps({ isActive: true });
expect(wrapper.contains('.is-active')).toBe(true);
wrapper.setProps({ isActive: false });
expect(wrapper.contains('.is-active')).toBe(false);
});
});