react-select-event
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24883
449
157
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@testing-library/dom@10.4.0(transitive)
+ Added@types/aria-query@5.0.4(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.05.2.0(transitive)
+ Addedaria-query@5.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddom-accessibility-api@0.5.16(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedlz-string@1.5.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpretty-format@27.5.1(transitive)
+ Addedreact-is@17.0.2(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removed@jest/types@24.9.0(transitive)
- Removed@sheerun/mutationobserver-shim@0.3.3(transitive)
- Removed@testing-library/dom@5.6.1(transitive)
- Removed@types/istanbul-lib-coverage@2.0.6(transitive)
- Removed@types/istanbul-lib-report@3.0.3(transitive)
- Removed@types/istanbul-reports@1.1.2(transitive)
- Removed@types/yargs@13.0.12(transitive)
- Removed@types/yargs-parser@21.0.3(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedaria-query@3.0.0(transitive)
- Removedast-types-flow@0.0.7(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommander@2.20.3(transitive)
- Removedpretty-format@24.9.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedwait-for-expect@1.3.0(transitive)
Updated@testing-library/dom@>=5