-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Query directly in finders in order to have get rid of build selector - breaking: ignore trailing spaces in selectors
- Loading branch information
Showing
15 changed files
with
572 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,35 @@ | ||
import { getter } from '../macros/index'; | ||
import { buildSelector } from './build-selector'; | ||
import { Query } from './query'; | ||
import { run } from './run'; | ||
|
||
export default function action(options, cb) { | ||
export default function action(options, callback) { | ||
return getter(function (key) { | ||
return function (...args) { | ||
({ options, cb } = normalizeArgs(key, options, cb, args)); | ||
|
||
const node = this; | ||
return run( | ||
{ | ||
node, | ||
filters: { | ||
...options, | ||
}, | ||
}, | ||
() => { | ||
return cb.bind(this)(...args); | ||
} | ||
const { locator, cb, label } = normalizeArgs( | ||
key, | ||
options, | ||
callback, | ||
args | ||
); | ||
|
||
const query = new Query(this, locator); | ||
|
||
return run(query, label, () => { | ||
return cb.bind(this)(...args); | ||
}); | ||
}; | ||
}); | ||
} | ||
|
||
function normalizeArgs(key, options, cb, args) { | ||
const formattedKey = `${key}(${ | ||
function normalizeArgs(key, locator, cb, args) { | ||
const label = `${key}(${ | ||
args.length ? `"${args.map((a) => String(a)).join('", "')}"` : `` | ||
})`; | ||
|
||
if (typeof options === 'function') { | ||
cb = options; | ||
options = { | ||
pageObjectKey: formattedKey, | ||
}; | ||
} else { | ||
options = { | ||
...options, | ||
pageObjectKey: formattedKey, | ||
}; | ||
if (typeof locator === 'function') { | ||
cb = locator; | ||
locator = {}; | ||
} | ||
|
||
return { options, cb }; | ||
return { locator, cb, label }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.