@testing-library/user-event 10.3.5 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
  [![MIT License][license-badge]][license]
24
24
 
25
25
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
26
- [![All Contributors](https://img.shields.io/badge/all_contributors-31-orange.svg?style=flat-square)](#contributors-)
26
+ [![All Contributors](https://img.shields.io/badge/all_contributors-32-orange.svg?style=flat-square)](#contributors-)
27
27
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
28
28
  [![PRs Welcome][prs-badge]][prs]
29
29
  [![Code of Conduct][coc-badge]][coc]
@@ -272,6 +272,15 @@ test('selectOptions', () => {
272
272
  The `values` parameter can be either an array of values or a singular scalar
273
273
  value.
274
274
 
275
+ It also accepts option nodes:
276
+
277
+ ```js
278
+ userEvent.selectOptions(screen.getByTestId('select-multiple'), [
279
+ screen.getByText('A'),
280
+ screen.getByText('B'),
281
+ ])
282
+ ```
283
+
275
284
  ### `tab({shift, focusTrap})`
276
285
 
277
286
  Fires a tab event changing the document.activeElement in the same way the
@@ -395,6 +404,7 @@ Thanks goes to these people ([emoji key][emojis]):
395
404
  <td align="center"><a href="https://proling.ru/"><img src="https://avatars2.githubusercontent.com/u/16336572?v=4" width="100px;" alt=""/><br /><sub><b>Vadim Shvetsov</b></sub></a><br /><a href="#ideas-vadimshvetsov" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/user-event/commits?author=vadimshvetsov" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=vadimshvetsov" title="Tests">⚠️</a></td>
396
405
  <td align="center"><a href="https://github.com/9still"><img src="https://avatars0.githubusercontent.com/u/4924760?v=4" width="100px;" alt=""/><br /><sub><b>Greg Shtilman</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=9still" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=9still" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/issues?q=author%3A9still" title="Bug reports">🐛</a></td>
397
406
  <td align="center"><a href="https://github.com/rbusquet"><img src="https://avatars1.githubusercontent.com/u/7198302?v=4" width="100px;" alt=""/><br /><sub><b>Ricardo Busquet</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Arbusquet" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/user-event/commits?author=rbusquet" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=rbusquet" title="Tests">⚠️</a></td>
407
+ <td align="center"><a href="https://www.linkedin.com/in/dougbacelar/en"><img src="https://avatars3.githubusercontent.com/u/9267678?v=4" width="100px;" alt=""/><br /><sub><b>Doug Bacelar</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=dougbacelar" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=dougbacelar" title="Tests">⚠️</a></td>
398
408
  </tr>
399
409
  </table>
400
410
 
package/dist/index.js CHANGED
@@ -333,7 +333,7 @@ function selectOptions(element, values, init) {
333
333
 
334
334
  clickElement(element, previouslyFocusedElement, init);
335
335
  const valArray = Array.isArray(values) ? values : [values];
336
- const selectedOptions = Array.from(element.querySelectorAll('option')).filter(opt => valArray.includes(opt.value));
336
+ const selectedOptions = Array.from(element.querySelectorAll('option')).filter(opt => valArray.includes(opt.value) || valArray.includes(opt));
337
337
 
338
338
  if (selectedOptions.length > 0) {
339
339
  if (element.multiple) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "10.3.5",
3
+ "version": "10.4.0",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "typings": "typings/index.d.ts",
@@ -22,7 +22,11 @@ declare const userEvent: {
22
22
  clear: (element: TargetElement) => void
23
23
  click: (element: TargetElement, init?: MouseEventInit) => void
24
24
  dblClick: (element: TargetElement, init?: MouseEventInit) => void
25
- selectOptions: (element: TargetElement, values: string | string[], init?: MouseEventInit) => void
25
+ selectOptions: (
26
+ element: TargetElement,
27
+ values: string | string[] | HTMLElement | HTMLElement[],
28
+ init?: MouseEventInit,
29
+ ) => void
26
30
  upload: (
27
31
  element: TargetElement,
28
32
  files: FilesArgument,