-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added KMenu onOpenChange unit test
- Loading branch information
baiwusanyu-c
committed
Jan 8, 2025
1 parent
5d17ab5
commit db152a7
Showing
8 changed files
with
326 additions
and
25 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<script lang="ts"> | ||
import { KMenu, KMenuItem } from '@ikun-ui/menu'; | ||
import type { SubMenuType } from '@ikun-ui/menu'; | ||
let items: SubMenuType[] = [ | ||
{ | ||
label: 'Navigation Three - Su', | ||
title: 'Navigation Three - Su', | ||
uid: 'SubMenu', | ||
popupClassName: 'ikun-test', | ||
icon: 'i-carbon-logo-vue', | ||
children: [ | ||
{ | ||
type: 'group', | ||
label: 'Item 1', | ||
title: 'Item 1', | ||
popupClassName: 'ikun-test', | ||
uid: 'asda', | ||
// icon: 'i-carbon-logo-vue', | ||
children: [ | ||
{ | ||
label: 'Option 1', | ||
title: 'Option 1', | ||
uid: 'setting:1', | ||
popupClassName: 'ikun-test', | ||
disabled: false, | ||
// icon: 'i-carbon-logo-vue', | ||
children: [ | ||
{ | ||
label: 'Option 3333 Option 3333 Option 3333', | ||
title: 'Option 3333', | ||
icon: 'i-carbon-logo-vue', | ||
popupClassName: 'ikun-test', | ||
uid: 'setting:3333' | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'Navigation Four-dv', | ||
// icon: 'i-carbon-logo-react', | ||
type: 'divider', | ||
popupClassName: 'ikun-test', | ||
uid: 'alipay-dv' | ||
}, | ||
{ | ||
label: 'Option 2', | ||
popupClassName: 'ikun-test', | ||
uid: 'setting:2' | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'Item 2', | ||
uid: 'asdqqda', | ||
disabled: true, | ||
popupClassName: 'ikun-test', | ||
// icon: 'i-carbon-logo-vue', | ||
children: [ | ||
{ | ||
label: 'Option 3', | ||
popupClassName: 'ikun-test', | ||
uid: 'setting:3' | ||
}, | ||
{ | ||
label: 'Option 4', | ||
popupClassName: 'ikun-test', | ||
uid: 'setting:4' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]; | ||
let triggerTime = 0; | ||
let res = {}; | ||
const handleClick = (item: CustomEvent) => { | ||
res = item.detail; | ||
triggerTime = triggerTime + 1; | ||
}; | ||
</script> | ||
|
||
<div class="w-full fsc"> | ||
<KMenu | ||
mode="vertical" | ||
id="open_change_test_vertical" | ||
on:openChange={handleClick} | ||
triggerSubMenuAction="click" | ||
ctxKey="11" | ||
> | ||
<KMenuItem {items} ctxKey="11" /> | ||
</KMenu> | ||
<KMenu | ||
mode="inline" | ||
id="open_change_test_inline" | ||
triggerSubMenuAction="click" | ||
on:openChange={handleClick} | ||
ctxKey="22" | ||
> | ||
<KMenuItem {items} ctxKey="22" /> | ||
</KMenu> | ||
<KMenu | ||
mode="horizontal" | ||
id="open_change_test_horizontal" | ||
triggerSubMenuAction="click" | ||
on:openChange={handleClick} | ||
ctxKey="33" | ||
> | ||
<KMenuItem {items} ctxKey="33" /> | ||
</KMenu> | ||
<div id="trigger_time">{triggerTime}</div> | ||
<div>{JSON.stringify(res)}</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.