Skip to content

Commit 54b9a5f

Browse files
G-Ratheps1lon
andauthored
fix: support getting text of inputs of type reset (#1011)
Co-authored-by: eps1lon <[email protected]>
1 parent 91b9dc3 commit 54b9a5f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/__tests__/element-queries.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ test('can get elements by matching their text across adjacent text nodes', () =>
133133
expect(queryByText('£24.99')).toBeTruthy()
134134
})
135135

136-
test('can get input elements with type submit or button', () => {
136+
test('can get input elements with type submit, button, or reset', () => {
137137
const {queryByText} = render(`
138138
<div>
139139
<input type="submit" value="Send data"/>
140+
<input type="reset" value="Clear EVERYTHING"/>
140141
<input type="button" value="Push me!"/>
141142
<input type="text" value="user data" />
142143
</div>
143144
`)
144145
expect(queryByText('Send data')).toBeTruthy()
146+
expect(queryByText('Clear EVERYTHING')).toBeTruthy()
145147
expect(queryByText('Push me!')).toBeTruthy()
146148
expect(queryByText('user data')).toBeFalsy()
147149
})

src/get-node-text.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {TEXT_NODE} from './helpers'
22

33
function getNodeText(node: HTMLElement): string {
4-
if (node.matches('input[type=submit], input[type=button]')) {
4+
if (
5+
node.matches('input[type=submit], input[type=button], input[type=reset]')
6+
) {
57
return (node as HTMLInputElement).value
68
}
79

0 commit comments

Comments
 (0)