mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
test(combo-box): add unit tests
This commit is contained in:
parent
d25a85c825
commit
0e1177f398
4 changed files with 271 additions and 77 deletions
36
tests/ComboBox/ComboBoxCustom.test.svelte
Normal file
36
tests/ComboBox/ComboBoxCustom.test.svelte
Normal file
|
@ -0,0 +1,36 @@
|
|||
<script lang="ts">
|
||||
import { ComboBox } from "carbon-components-svelte";
|
||||
import type { ComboBoxItem } from "carbon-components-svelte/ComboBox/ComboBox.svelte";
|
||||
|
||||
let comboBoxRef: ComboBox;
|
||||
|
||||
export let items: ComboBoxItem[] = [
|
||||
{ id: "0", text: "Slack" },
|
||||
{ id: "1", text: "Email" },
|
||||
{ id: "2", text: "Fax", disabled: true },
|
||||
];
|
||||
export let selectedId: string | undefined = undefined;
|
||||
export let direction: "top" | "bottom" = "bottom";
|
||||
export let shouldFilterItem = (item: ComboBoxItem, value: string) =>
|
||||
item.text.toLowerCase().includes(value.toLowerCase());
|
||||
export let itemToString = (item: ComboBoxItem) => item.text;
|
||||
</script>
|
||||
|
||||
<ComboBox
|
||||
bind:this={comboBoxRef}
|
||||
{items}
|
||||
{selectedId}
|
||||
{direction}
|
||||
{shouldFilterItem}
|
||||
{itemToString}
|
||||
titleText="Contact with icons"
|
||||
placeholder="Select contact method"
|
||||
on:select={(e) => {
|
||||
console.log("select", e.detail);
|
||||
}}
|
||||
let:item
|
||||
>
|
||||
<span>Item {item.text}</span>
|
||||
</ComboBox>
|
||||
|
||||
<button type="button" on:click={() => comboBoxRef.clear()}>Clear</button>
|
Loading…
Add table
Add a link
Reference in a new issue