Skip to content

Add a reference to react-select-event #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions docs/ecosystem-react-select-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
id: ecosystem-react-select-event
title: react-select-event
---

[`react-select-event`][gh] is a companion library for `react-testing-library`
that provides helper methods for interacting with [`react-select`][react-select]
elements.

```
npm install --save-dev react-select-event
```

```jsx
import React from 'react'
import Select from 'react-select'
import { render } from 'react-testing-library'
import selectEvent from 'react-select-event'

const { getByTestId, getByLabelText } = render(
<form data-testid="form">
<label htmlFor="food">Food</label>
<Select options={OPTIONS} name="food" inputId="food" isMulti />
</form>
)
expect(getByTestId('form')).toHaveFormValues({ food: '' }) // empty select

// select two values...
await selectEvent.select(getByLabelText('Food'), ['Strawberry', 'Mango'])
expect(getByTestId('form')).toHaveFormValues({ food: ['strawberry', 'mango'] })

// ...and add a third one
await selectEvent.select(getByLabelText('Food'), 'Chocolate')
expect(getByTestId('form')).toHaveFormValues({
food: ['strawberry', 'mango', 'chocolate'],
})
```

- [react-select-event on GitHub][gh]

[gh]: https://github.com/romgain/react-select-event
[react-select]: https://github.com/JedWatson/react-select
3 changes: 2 additions & 1 deletion website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"ecosystem-user-event",
"ecosystem-jest-dom",
"ecosystem-bs-jest-dom",
"ecosystem-jest-native"
"ecosystem-jest-native",
"ecosystem-react-select-event"
],
"Help": ["faq", "learning", "contributing"]
},
Expand Down