Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/__tests__/select-event.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,31 @@ describe("The select event helpers", () => {
expect(form).toHaveFormValues({ food: "vanilla" });
});

it("selects options when there are multiple dropdowns", async () => {
const {container, getByRole} = render(
<form role="form">
<label htmlFor="food-for-monday">Food for monday</label>
<Select
options={OPTIONS} name="foodForMonday" inputId="food-for-monday"
formatOptionLabel={({ label }) => <div>This is a {label}</div>}
/>
<label htmlFor="food-for-tuesday">Food for tuesday</label>
<Select
options={OPTIONS} name="foodForTuesday" inputId="food-for-tuesday"
formatOptionLabel={({ label }) => <div>This is a {label}</div>}
/>
</form>
);
const form = getByRole("form");
const mondayInput = container.querySelector('input[name="foodForMonday"]')
const tuesdayInput = container.querySelector('input[name="foodForTuesday"]')

expect(form).toHaveFormValues({ foodForMonday: "", foodForTuesday: "" });
await selectEvent.select(mondayInput, /Chocolate/);
await selectEvent.select(tuesdayInput, /Chocolate/);
expect(form).toHaveFormValues({ foodForMonday: "chocolate", foodForTuesday: "chocolate" });
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail, as foodForTuesday is ""

});

describe("when asynchronously generating the list of options", () => {
// from https://github.com/JedWatson/react-select/blob/v3.0.0/docs/examples/CreatableAdvanced.js
// mixed with Async Creatable Example from https://react-select.com/creatable
Expand Down