File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 1
- export default async function getElements ( selectorOrPromise , client ) {
2
- if ( selectorOrPromise instanceof Promise ) {
3
- const resolved = await selectorOrPromise
4
- const selector = selectorOrPromise . selector || String ( resolved )
5
- if ( typeof resolved === 'string' ) selectorOrPromise = resolved
1
+ export default async function getElements ( obj , client ) {
2
+ if ( obj instanceof Promise ) {
3
+ const resolved = await obj
4
+ const selector = obj . selector || String ( resolved )
5
+ if ( typeof resolved === 'string' ) obj = resolved
6
6
else if ( Array . isArray ( resolved ) ) return [ resolved , selector ]
7
7
else if ( resolved ) return [ [ resolved ] , selector ]
8
8
}
9
-
10
- return typeof selectorOrPromise === 'string'
11
- ? [ await client . $$ ( selectorOrPromise ) , selectorOrPromise ]
12
- : [ [ ] , selectorOrPromise ]
9
+ if ( Array . isArray ( obj ) ) return [ obj , obj . join ( ', ' ) ]
10
+ if ( typeof obj === 'string' ) return [ await client . $$ ( obj ) , obj ]
11
+ if ( obj ) return [ [ obj ] , String ( obj ) ]
12
+ return [ [ ] , String ( obj ) ]
13
13
}
Original file line number Diff line number Diff line change @@ -36,10 +36,22 @@ export const booleanAssertionTest = ({
36
36
fakeElement1 [ `is${ upperFirst ( method ) } ` ] . resolves ( true )
37
37
await expect ( '.some-selector' ) . to . be [ method ] ( )
38
38
} )
39
- it ( `resolves when element is ${ expectation } -- via promise` , async function ( ) {
39
+ it ( `resolves when element is ${ expectation } -- via promise resolving to array` , async function ( ) {
40
+ fakeElement1 [ `is${ upperFirst ( method ) } ` ] . resolves ( true )
41
+ await expect ( Promise . resolve ( [ fakeElement1 ] ) ) . to . be [ method ] ( )
42
+ } )
43
+ it ( `resolves when element is ${ expectation } -- via promise resolving to element` , async function ( ) {
40
44
fakeElement1 [ `is${ upperFirst ( method ) } ` ] . resolves ( true )
41
45
await expect ( Promise . resolve ( fakeElement1 ) ) . to . be [ method ] ( )
42
46
} )
47
+ it ( `resolves when element is ${ expectation } -- via array` , async function ( ) {
48
+ fakeElement1 [ `is${ upperFirst ( method ) } ` ] . resolves ( true )
49
+ await expect ( [ fakeElement1 ] ) . to . be [ method ] ( )
50
+ } )
51
+ it ( `resolves when element is ${ expectation } -- via element` , async function ( ) {
52
+ fakeElement1 [ `is${ upperFirst ( method ) } ` ] . resolves ( true )
53
+ await expect ( fakeElement1 ) . to . be [ method ] ( )
54
+ } )
43
55
it ( `rejects when element is not ${ expectation } ` , async function ( ) {
44
56
await expect ( '.some-selector' )
45
57
. to . be [ method ] ( )
You can’t perform that action at this time.
0 commit comments