blob: 0370d5e337d41aade1272d3f861150e93f3f4d01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import { GlButton } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import ToggleSidebar from '~/sidebar/components/toggle/toggle_sidebar.vue';
describe('ToggleSidebar', () => {
let wrapper;
const defaultProps = {
collapsed: true,
};
const createComponent = ({ mountFn = shallowMount, props = {} } = {}) => {
wrapper = mountFn(ToggleSidebar, {
propsData: { ...defaultProps, ...props },
});
};
const findGlButton = () => wrapper.findComponent(GlButton);
it('should render the "chevron-double-lg-left" icon when collapsed', () => {
createComponent();
expect(findGlButton().props('icon')).toBe('chevron-double-lg-left');
});
it('should render the "chevron-double-lg-right" icon when expanded', async () => {
createComponent({ props: { collapsed: false } });
expect(findGlButton().props('icon')).toBe('chevron-double-lg-right');
});
it('should emit toggle event when button clicked', async () => {
createComponent({ mountFn: mount });
findGlButton().trigger('click');
await nextTick();
expect(wrapper.emitted('toggle')[0]).toBeDefined();
});
});
|