diff --git a/docs/ecosystem-react-select-event.md b/docs/ecosystem-react-select-event.md new file mode 100644 index 000000000..dbbd47f96 --- /dev/null +++ b/docs/ecosystem-react-select-event.md @@ -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( +
+) +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 diff --git a/website/sidebars.json b/website/sidebars.json index b7514c0a6..f984aeced 100755 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -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"] },