debian-mirror-gitlab/spec/frontend/super_sidebar/components/create_menu_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2 KiB
JavaScript
Raw Normal View History

2023-06-20 00:43:36 +05:30
import { nextTick } from 'vue';
2023-04-23 21:23:45 +05:30
import { GlDisclosureDropdown, GlTooltip } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { __ } from '~/locale';
import CreateMenu from '~/super_sidebar/components/create_menu.vue';
import { createNewMenuGroups } from '../mock_data';
describe('CreateMenu component', () => {
let wrapper;
const findGlDisclosureDropdown = () => wrapper.findComponent(GlDisclosureDropdown);
const findGlTooltip = () => wrapper.findComponent(GlTooltip);
const createWrapper = () => {
wrapper = shallowMountExtended(CreateMenu, {
propsData: {
groups: createNewMenuGroups,
},
});
};
describe('default', () => {
beforeEach(() => {
createWrapper();
});
2023-06-20 00:43:36 +05:30
it('passes popper options to the dropdown', () => {
createWrapper();
expect(findGlDisclosureDropdown().props('popperOptions')).toEqual({
modifiers: [{ name: 'offset', options: { offset: [-147, 4] } }],
});
});
2023-04-23 21:23:45 +05:30
it("sets the toggle's label", () => {
expect(findGlDisclosureDropdown().props('toggleText')).toBe(__('Create new...'));
});
it('passes the groups to the disclosure dropdown', () => {
expect(findGlDisclosureDropdown().props('items')).toBe(createNewMenuGroups);
});
it("sets the toggle ID and tooltip's target", () => {
expect(findGlDisclosureDropdown().props('toggleId')).toBe(wrapper.vm.$options.toggleId);
expect(findGlTooltip().props('target')).toBe(`#${wrapper.vm.$options.toggleId}`);
});
2023-06-20 00:43:36 +05:30
it('hides the tooltip when the dropdown is opened', async () => {
findGlDisclosureDropdown().vm.$emit('shown');
await nextTick();
expect(findGlTooltip().exists()).toBe(false);
});
it('shows the tooltip when the dropdown is closed', async () => {
findGlDisclosureDropdown().vm.$emit('shown');
findGlDisclosureDropdown().vm.$emit('hidden');
await nextTick();
expect(findGlTooltip().exists()).toBe(true);
});
2023-04-23 21:23:45 +05:30
});
});