mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(select): falsy item text
should not override value
(#2118)
Fixes #2117
This commit is contained in:
parent
49f9cb00ed
commit
663b79ad05
3 changed files with 18 additions and 1 deletions
9
tests/Select/Select.falsy.test.svelte
Normal file
9
tests/Select/Select.falsy.test.svelte
Normal file
|
@ -0,0 +1,9 @@
|
|||
<script lang="ts">
|
||||
import { Select, SelectItem } from "carbon-components-svelte";
|
||||
</script>
|
||||
|
||||
<Select labelText="Falsy text">
|
||||
<SelectItem value={-1} text="" />
|
||||
<SelectItem value={0} text="Zero" />
|
||||
<SelectItem value={1} text="One" />
|
||||
</Select>
|
|
@ -3,6 +3,7 @@ import { user } from "../setup-tests";
|
|||
import Select from "./Select.test.svelte";
|
||||
import SelectGroup from "./Select.group.test.svelte";
|
||||
import SelectSkeleton from "./Select.skeleton.test.svelte";
|
||||
import SelectFalsy from "./Select.falsy.test.svelte";
|
||||
|
||||
describe("Select", () => {
|
||||
beforeEach(() => {
|
||||
|
@ -238,4 +239,11 @@ describe("Select", () => {
|
|||
expect(skeleton).toBeInTheDocument();
|
||||
expect(skeleton.children[0]).toHaveClass("bx--skeleton");
|
||||
});
|
||||
|
||||
it("renders value if `text` is falsy", () => {
|
||||
render(SelectFalsy);
|
||||
|
||||
expect(screen.getByLabelText("Falsy text")).toHaveValue("-1");
|
||||
expect(screen.getByDisplayValue("")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue