react-select-event
Advanced tools
Comparing version
@@ -13,3 +13,3 @@ /** Simulate user events on react-select dropdowns */ | ||
*/ | ||
export declare const create: (input: HTMLElement, option: string) => void; | ||
export declare const create: (input: HTMLElement, option: string) => Promise<void>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Utility for clearing the first value of a `react-select` dropdown. | ||
select: (input: HTMLElement, optionOrOptions: string | string[]) => Promise<void>; | ||
create: (input: HTMLElement, option: string) => void; | ||
create: (input: HTMLElement, option: string) => Promise<void>; | ||
clearFirst: (input: HTMLElement) => void; | ||
@@ -30,0 +30,0 @@ clearAll: (input: HTMLElement) => void; |
@@ -54,3 +54,3 @@ 'use strict'; | ||
const create = (input, option) => { | ||
const create = async (input, option) => { | ||
focus(input); | ||
@@ -64,2 +64,3 @@ type(input, option); // hit Enter to add the item | ||
}); | ||
await dom.findByText(getReactSelectContainerFromInput(input), option); | ||
}; | ||
@@ -66,0 +67,0 @@ /** |
@@ -50,3 +50,3 @@ import { findByText, fireEvent, getByText } from '@testing-library/dom'; | ||
const create = (input, option) => { | ||
const create = async (input, option) => { | ||
focus(input); | ||
@@ -60,2 +60,3 @@ type(input, option); // hit Enter to add the item | ||
}); | ||
await findByText(getReactSelectContainerFromInput(input), option); | ||
}; | ||
@@ -62,0 +63,0 @@ /** |
{ | ||
"name": "react-select-event", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Simulate react-select events for react-testing-library", | ||
@@ -39,3 +39,3 @@ "main": "lib/react-select-event.cjs.js", | ||
"dependencies": { | ||
"@testing-library/dom": "^5.5.2" | ||
"@testing-library/dom": ">=5" | ||
}, | ||
@@ -50,3 +50,3 @@ "devDependencies": { | ||
"@testing-library/jest-dom": "^4.0.0", | ||
"@testing-library/react": "^8.0.4", | ||
"@testing-library/react": "^9.1.3", | ||
"@types/jest": "^24.0.13", | ||
@@ -57,4 +57,4 @@ "@types/react": "^16.8.19", | ||
"prettier": "^1.17.1", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"react": "^16.9.0", | ||
"react-dom": "^16.9.0", | ||
"react-select": "^2.4.3", | ||
@@ -61,0 +61,0 @@ "rimraf": "^2.6.3", |
@@ -63,2 +63,27 @@ <div align="center"> | ||
This also works for [async selects](https://react-select.com/async): | ||
```jsx | ||
const { getByTestId, getByLabelText } = render( | ||
<form data-testid="form"> | ||
<label htmlFor="food">Food</label> | ||
<Async | ||
options={[]} | ||
loadOptions={fetchTheOptions} | ||
name="food" | ||
inputId="food" | ||
isMulti | ||
/> | ||
</form> | ||
); | ||
expect(getByTestId("form")).toHaveFormValues({ food: "" }); | ||
// start typing to trigger the `loadOptions` | ||
fireEvent.change(getByLabelText("Food"), { target: { value: "Choc" } }); | ||
await selectEvent.select(getByLabelText("Food"), "Chocolate"); | ||
expect(getByTestId("form")).toHaveFormValues({ | ||
food: ["chocolate"] | ||
}); | ||
``` | ||
### `create(input: HTMLElement, option: string): void` | ||
@@ -65,0 +90,0 @@ |
@@ -53,3 +53,3 @@ /** Simulate user events on react-select dropdowns */ | ||
*/ | ||
export const create = (input: HTMLElement, option: string) => { | ||
export const create = async (input: HTMLElement, option: string) => { | ||
focus(input); | ||
@@ -63,2 +63,3 @@ type(input, option); | ||
}); | ||
await findByText(getReactSelectContainerFromInput(input), option); | ||
}; | ||
@@ -65,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
24883
15.69%449
16.93%157
18.94%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated