mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-17 11:11:25 +00:00
SelectItem: fix to use the value when text is undefined after #2118
This commit is contained in:
parent
896c16a6be
commit
4295e9740c
6 changed files with 30 additions and 15 deletions
|
@ -7,3 +7,8 @@
|
|||
<SelectItem value={0} text="Zero" />
|
||||
<SelectItem value={1} text="One" />
|
||||
</Select>
|
||||
<Select labelText="Undefined text">
|
||||
<SelectItem value={2} />
|
||||
<SelectItem value={0} text="Zero" />
|
||||
<SelectItem value={1} text="One" />
|
||||
</Select>
|
||||
|
|
|
@ -240,10 +240,16 @@ describe("Select", () => {
|
|||
expect(skeleton.children[0]).toHaveClass("bx--skeleton");
|
||||
});
|
||||
|
||||
it("renders value if `text` is falsy", () => {
|
||||
it("renders `text` instead of `value` if `text` is an empty string", () => {
|
||||
render(SelectFalsy);
|
||||
|
||||
expect(screen.getByLabelText("Falsy text")).toHaveValue("-1");
|
||||
expect(screen.getByDisplayValue("")).toBeInTheDocument();
|
||||
expect(screen.getByRole('option', { name: "" })).toBeInTheDocument();
|
||||
});
|
||||
it("renders value if `text` is undefined", () => {
|
||||
render(SelectFalsy);
|
||||
|
||||
expect(screen.getByLabelText("Undefined text")).toHaveValue("2");
|
||||
expect(screen.getByRole('option', { name: "2" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue