import { ElementCondition , NullableLocatable } from '../Condition' ; import { EvaluateFn } from '../types' ; export class ElementTextCondition extends ElementCondition { constructor ( desc , locator , ... args ) { super ( desc , locator ) ; this . pageFuncArgs = args ; } toString ( ) { return `waiting for element text to equal "${ this . pageFuncArgs [ 0 ] }"` ; } pageFunc : EvaluateFn = ( node , expectedText , partial = false ) => { if ( ! node ) return false ; if ( ! node . textContent ) return false ; const text = node . textContent . trim ( ) ; if ( typeof expectedText === 'string' ) { if ( expectedText . startsWith ( '/' ) && expectedText . endsWith ( '/' ) ) { const exp = new RegExp ( expectedText . slice ( 1 , expectedText . length - 1 ) ) ; return exp . test ( text ) ; } else { return ( partial && text . indexOf ( expectedText ) !== - 1 ) || text === expectedText ; } } return false ; } ; async waitForEvent ( ) { return ; } }