@@ -1391,14 +1391,14 @@ export class InjectedScript {
1391
1391
1392
1392
{
1393
1393
// Single text value.
1394
- let received : string | undefined ;
1394
+ let received : string | string [ ] | undefined ;
1395
1395
if ( expression === 'to.have.attribute.value' ) {
1396
1396
const value = element . getAttribute ( options . expressionArg ) ;
1397
1397
if ( value === null )
1398
1398
return { received : null , matches : false } ;
1399
1399
received = value ;
1400
1400
} else if ( expression === 'to.have.class' ) {
1401
- received = element . classList . toString ( ) ;
1401
+ received = options . expressionArg . partial ? element . classList . toString ( ) : [ ... element . classList ] ;
1402
1402
} else if ( expression === 'to.have.css' ) {
1403
1403
received = this . window . getComputedStyle ( element ) . getPropertyValue ( options . expressionArg ) ;
1404
1404
} else if ( expression === 'to.have.id' ) {
@@ -1443,11 +1443,11 @@ export class InjectedScript {
1443
1443
}
1444
1444
1445
1445
// List of values.
1446
- let received : string [ ] | undefined ;
1446
+ let received : ( string | string [ ] ) [ ] | undefined ;
1447
1447
if ( expression === 'to.have.text.array' || expression === 'to.contain.text.array' )
1448
1448
received = elements . map ( e => options . useInnerText ? ( e as HTMLElement ) . innerText : elementText ( new Map ( ) , e ) . full ) ;
1449
1449
else if ( expression === 'to.have.class.array' )
1450
- received = elements . map ( e => e . classList . toString ( ) ) ;
1450
+ received = elements . map ( e => options . expressionArg . partial ? [ ... e . classList ] : e . classList . toString ( ) ) ;
1451
1451
1452
1452
if ( received && options . expectedText ) {
1453
1453
// "To match an array" is "to contain an array" + "equal length"
@@ -1611,7 +1611,9 @@ class ExpectedTextMatcher {
1611
1611
}
1612
1612
}
1613
1613
1614
- matches ( text : string ) : boolean {
1614
+ matches ( text : string | string [ ] ) : boolean {
1615
+ if ( Array . isArray ( text ) )
1616
+ return text . some ( t => this . matches ( t ) ) ;
1615
1617
if ( ! this . _regex )
1616
1618
text = this . normalize ( text ) ! ;
1617
1619
if ( this . _string !== undefined )
0 commit comments