You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(queryByCurrentValue): add get/query by current value (#169)
* feat(queryByCurrentValue): add get/query by current value
* feat(queryByCurrentValue): exports (query|get)AllByCurrentValue
* chore: change the order of exports
* fix: add implementation for `select` element at `queryAllByCurrentValue`
* chore: add tests for get/queryByCurrentValue
* chore: add test for getAllByCurrentValue to throw
* chore: rename xxxByCurrentValue -> xxxByDisplayValue
* docs: add `getByDisplayValue`
* docs: add `eunjae-lee` as a contributor
* docs: remove `getByAltText`, `getByTitle` and `getByValue`
* docs: update `getByDisplayValue`
* chore: add test for 100% coverage
* docs: remove unnecessary `console.log(...)`
* Revert "docs: remove `getByAltText`, `getByTitle` and `getByValue`"
This reverts commit c960865.
* docs: remove `getBySelectText` and `getByValue`
* docs: update description on `getByDisplayName`
> NOTE: a placeholder is not a good substitute for a label so you should
277
276
> generally use `getByLabelText` instead.
278
277
279
-
### `getBySelectText`
280
-
281
-
```typescript
282
-
getBySelectText(
283
-
container: HTMLElement,
284
-
text: TextMatch,
285
-
options?: {
286
-
exact?: boolean=true,
287
-
collapseWhitespace?: boolean=true,
288
-
trim?: boolean=true,
289
-
}): HTMLElement
290
-
```
291
-
292
-
This will search for a `<select>` whose selected `<option>` matches the given [`TextMatch`](#textmatch). This would find the `<select>` node in a situation
293
-
where the first value acts as a sort of placeholder for the dropdown.
294
-
295
-
```javascript
296
-
// <select>
297
-
// <option value="">Day of the Week</option>
298
-
// <option value="1">Monday</option>
299
-
// <option value="2">Tuesday</option>
300
-
// <option value="3">Wednesday</option>
301
-
// </select>
302
-
constselectNode=getBySelectText(container, 'Day of the Week')
303
-
```
304
-
305
-
> Note: It is highly preferred to use `getByLabelText` over this method. This
306
-
> method should only be used in the event where there is no label text available.
307
-
308
278
### `getByText`
309
279
310
280
```typescript
@@ -390,10 +360,10 @@ Will also find a `title` element within an SVG.
390
360
constcloseElement=getByTitle(container, 'Close')
391
361
```
392
362
393
-
### `getByValue`
363
+
### `getByDisplayValue`
394
364
395
365
```typescript
396
-
getByValue(
366
+
getByDisplayValue(
397
367
container: HTMLElement,
398
368
value: TextMatch,
399
369
options?: {
@@ -403,13 +373,41 @@ getByValue(
403
373
}): HTMLElement
404
374
```
405
375
406
-
Returns the element that has the matching value.
376
+
Returns the `input`, `textarea`, or `select` element that has the matching display value.
0 commit comments