mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
test(context-menu): add unit tests
This commit is contained in:
parent
a862de1922
commit
349201a35d
3 changed files with 137 additions and 58 deletions
29
tests/ContextMenu/ContextMenu.test.svelte
Normal file
29
tests/ContextMenu/ContextMenu.test.svelte
Normal file
|
@ -0,0 +1,29 @@
|
|||
<script lang="ts">
|
||||
import { ContextMenu, ContextMenuOption } from "carbon-components-svelte";
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
export let target: ComponentProps<ContextMenu>["target"] = null;
|
||||
export let open = false;
|
||||
export let x = 0;
|
||||
export let y = 0;
|
||||
export let ref: ComponentProps<ContextMenu>["ref"] = null;
|
||||
</script>
|
||||
|
||||
<div data-testid="target">Right click me</div>
|
||||
|
||||
<ContextMenu
|
||||
bind:target
|
||||
bind:open
|
||||
{x}
|
||||
{y}
|
||||
bind:ref
|
||||
on:open={(e) => {
|
||||
console.log("open", e.detail);
|
||||
}}
|
||||
on:close={() => {
|
||||
console.log("close");
|
||||
}}
|
||||
>
|
||||
<ContextMenuOption>Option 1</ContextMenuOption>
|
||||
<ContextMenuOption>Option 2</ContextMenuOption>
|
||||
</ContextMenu>
|
Loading…
Add table
Add a link
Reference in a new issue