Skip to content

Commit 1829dde

Browse files
committed
fix: convert to string in toHaveDisplayValue
1 parent ae4374b commit 1829dde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/__tests__/to-have-display-value.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,13 @@ test('it should throw if element is not valid', () => {
152152
`".toHaveDisplayValue() currently does not support input[type=\\"checkbox\\"], try with another matcher instead."`,
153153
)
154154
})
155+
156+
test('it should work with numbers', () => {
157+
const {queryByTestId} = render(`
158+
<select data-testid="select">
159+
<option value="">1</option>
160+
</select>
161+
`)
162+
163+
expect(queryByTestId('select')).toHaveDisplayValue(1)
164+
})

src/to-have-display-value.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function toHaveDisplayValue(htmlElement, expectedValue) {
2222
values.some(value =>
2323
expected instanceof RegExp
2424
? expected.test(value)
25-
: this.equals(value, expected),
25+
: this.equals(value, String(expected)),
2626
),
2727
).length
2828

0 commit comments

Comments
 (0)