-
Notifications
You must be signed in to change notification settings - Fork 1
/
DropdownMenu.test.ts
44 lines (32 loc) · 1.3 KB
/
DropdownMenu.test.ts
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
43
44
import {describe, expect, it} from 'vitest';
import DropdownMenu from '@/components/DropdownMenu';
import DropdownMenuItem from '@/components/DropdownMenuItem';
import {shallowMount} from '@vue/test-utils';
const items = [
{header: true, label: 'Item 1'},
{label: 'Item 3'},
{divider: true},
{label: 'Item 4', active: true},
];
describe('template', () => {
componentRenderTest(DropdownMenu, {props: {items}});
componentSlotRenderTest(DropdownMenu, 'prepend');
componentSlotRenderTest(DropdownMenu, 'items');
componentSlotRenderTest(DropdownMenu, 'item', {props: {items}});
componentSlotRenderTest(DropdownMenu, 'append');
it('emits event on click dropdown menu item', async() => {
const wrapper = shallowMount(DropdownMenu, {props: {items}});
await wrapper.findComponent(DropdownMenuItem).trigger('click');
expect(wrapper.emitted('click:item')[0]).toEqual([items[0]]);
});
it('forwards item class to DropdownMenuItem', () => {
const wrapper = shallowMount(DropdownMenu, {
props: {
itemClass: 'hello-there',
items,
},
});
const dropdownMenuItem = wrapper.findComponent(DropdownMenuItem);
expect(dropdownMenuItem.vm.itemClass).toBe('hello-there');
});
});