|
1 | | -import { Dropdown, Option } from "@salt-ds/core"; |
| 1 | +import { Dropdown, FormField, FormFieldLabel, Option } from "@salt-ds/core"; |
2 | 2 | import * as dropdownStories from "@stories/dropdown/dropdown.stories"; |
3 | 3 | import { composeStories } from "@storybook/react-vite"; |
4 | 4 | import { type KeyboardEventHandler, useRef, useState } from "react"; |
@@ -526,4 +526,31 @@ describe("Given a Dropdown", () => { |
526 | 526 | .should("exist") |
527 | 527 | .and("have.attr", "role", "listbox"); |
528 | 528 | }); |
| 529 | + |
| 530 | + describe("validation status", () => { |
| 531 | + it("should use its own validation status when not in a FormField", () => { |
| 532 | + cy.mount( |
| 533 | + <Dropdown validationStatus="warning"> |
| 534 | + <Option value={1}>1</Option> |
| 535 | + </Dropdown>, |
| 536 | + ); |
| 537 | + cy.findByRole("combobox").should("have.class", "saltDropdown-warning"); |
| 538 | + }); |
| 539 | + |
| 540 | + it("should prioritize the FormField validation status over its own", () => { |
| 541 | + cy.mount( |
| 542 | + <FormField validationStatus="error"> |
| 543 | + <FormFieldLabel>Field</FormFieldLabel> |
| 544 | + <Dropdown validationStatus="warning"> |
| 545 | + <Option value={1}>1</Option> |
| 546 | + </Dropdown> |
| 547 | + </FormField>, |
| 548 | + ); |
| 549 | + cy.findByRole("combobox").should("have.class", "saltDropdown-error"); |
| 550 | + cy.findByRole("combobox").should( |
| 551 | + "not.have.class", |
| 552 | + "saltDropdown-warning", |
| 553 | + ); |
| 554 | + }); |
| 555 | + }); |
529 | 556 | }); |
0 commit comments