mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
test(checkbox): test multiple checkbox reactivity
This commit is contained in:
parent
558404118d
commit
1bcdb53cc9
2 changed files with 131 additions and 0 deletions
28
tests/Checkbox/MultipleCheckboxes.test.svelte
Normal file
28
tests/Checkbox/MultipleCheckboxes.test.svelte
Normal file
|
@ -0,0 +1,28 @@
|
|||
<script lang="ts">
|
||||
import { Checkbox, Button } from "carbon-components-svelte";
|
||||
|
||||
export let values = ["Apple", "Banana", "Coconut"];
|
||||
export let group = values.slice(0, 2);
|
||||
|
||||
$: console.log("group changed:", group);
|
||||
</script>
|
||||
|
||||
{#each values as value, index}
|
||||
<Checkbox
|
||||
bind:group
|
||||
labelText={value}
|
||||
{value}
|
||||
data-testid={`checkbox-${index}`}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
<Button
|
||||
on:click={() => {
|
||||
group = ["Banana"];
|
||||
console.log("set to banana");
|
||||
}}
|
||||
>
|
||||
Set to ["Banana"]
|
||||
</Button>
|
||||
|
||||
<span data-testid="selected-values">{JSON.stringify(group)}</span>
|
Loading…
Add table
Add a link
Reference in a new issue