1
- import { matches , checkHtmlElement , getMessage } from './utils'
1
+ import { checkHtmlElement , getMessage } from './utils'
2
2
3
3
export function toHaveDisplayValue ( htmlElement , expectedValue ) {
4
4
checkHtmlElement ( htmlElement , toHaveDisplayValue , this )
@@ -18,10 +18,13 @@ export function toHaveDisplayValue(htmlElement, expectedValue) {
18
18
19
19
const values = getValues ( tagName , htmlElement )
20
20
const expectedValues = getExpectedValues ( expectedValue )
21
- const numberOfMatchesWithValues = getNumberOfMatchesBetweenArrays (
22
- values ,
23
- expectedValues ,
24
- )
21
+ const numberOfMatchesWithValues = expectedValues . filter ( expected =>
22
+ values . some ( value =>
23
+ expected instanceof RegExp
24
+ ? expected . test ( value )
25
+ : this . equals ( value , String ( expected ) ) ,
26
+ ) ,
27
+ ) . length
25
28
26
29
const matchedWithAllValues = numberOfMatchesWithValues === values . length
27
30
const matchedWithAllExpectedValues =
@@ -56,9 +59,3 @@ function getValues(tagName, htmlElement) {
56
59
function getExpectedValues ( expectedValue ) {
57
60
return expectedValue instanceof Array ? expectedValue : [ expectedValue ]
58
61
}
59
-
60
- function getNumberOfMatchesBetweenArrays ( arrayBase , array ) {
61
- return array . filter (
62
- expected => arrayBase . filter ( value => matches ( value , expected ) ) . length ,
63
- ) . length
64
- }
0 commit comments