Skip to content

Commit c77922b

Browse files
romgainKent C. Dodds
authored and
Kent C. Dodds
committed
Add a reference to react-select-event (#121)
romgain/react-select-event#2
1 parent adb1785 commit c77922b

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

docs/ecosystem-react-select-event.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
id: ecosystem-react-select-event
3+
title: react-select-event
4+
---
5+
6+
[`react-select-event`][gh] is a companion library for `react-testing-library`
7+
that provides helper methods for interacting with [`react-select`][react-select]
8+
elements.
9+
10+
```
11+
npm install --save-dev react-select-event
12+
```
13+
14+
```jsx
15+
import React from 'react'
16+
import Select from 'react-select'
17+
import { render } from 'react-testing-library'
18+
import selectEvent from 'react-select-event'
19+
20+
const { getByTestId, getByLabelText } = render(
21+
<form data-testid="form">
22+
<label htmlFor="food">Food</label>
23+
<Select options={OPTIONS} name="food" inputId="food" isMulti />
24+
</form>
25+
)
26+
expect(getByTestId('form')).toHaveFormValues({ food: '' }) // empty select
27+
28+
// select two values...
29+
await selectEvent.select(getByLabelText('Food'), ['Strawberry', 'Mango'])
30+
expect(getByTestId('form')).toHaveFormValues({ food: ['strawberry', 'mango'] })
31+
32+
// ...and add a third one
33+
await selectEvent.select(getByLabelText('Food'), 'Chocolate')
34+
expect(getByTestId('form')).toHaveFormValues({
35+
food: ['strawberry', 'mango', 'chocolate'],
36+
})
37+
```
38+
39+
- [react-select-event on GitHub][gh]
40+
41+
[gh]: https://github.com/romgain/react-select-event
42+
[react-select]: https://github.com/JedWatson/react-select

website/sidebars.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"ecosystem-user-event",
6262
"ecosystem-jest-dom",
6363
"ecosystem-bs-jest-dom",
64-
"ecosystem-jest-native"
64+
"ecosystem-jest-native",
65+
"ecosystem-react-select-event"
6566
],
6667
"Help": ["faq", "learning", "contributing"]
6768
},

0 commit comments

Comments
 (0)