-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor to support upcoming chai-wait-for approach
BREAKING CHANGE: rename .to.be.there() -> .to.be.existing(), add .to.be.focused()
- Loading branch information
1 parent
bb670f7
commit 404acde
Showing
34 changed files
with
1,163 additions
and
1,398 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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true, | ||
}) | ||
exports.default = immediately | ||
|
||
function immediately(client, chai, utils) { | ||
chai.Assertion.addChainableMethod('immediately', function() { | ||
utils.flag(this, 'immediately', true) | ||
}) | ||
} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
const atLeastOne = customize => (client, chai, utils, options) => | ||
async function(expected) { | ||
const selector = utils.flag(this, 'object') | ||
|
||
const { predicate, errorMsg, errorMsgNegate, notFoundMessage } = customize( | ||
selector, | ||
expected | ||
) | ||
|
||
const elements = await client.$$(selector) | ||
if (!elements.length) throw new chai.AssertionError(notFoundMessage) | ||
|
||
const filteredList = (await Promise.all(elements.map(predicate))).filter( | ||
Boolean | ||
) | ||
|
||
this.assert(filteredList.length > 0, errorMsg, errorMsgNegate) | ||
} | ||
|
||
export default atLeastOne |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
const booleanAssertion = ({ predicate, expectation, allowNone }) => ( | ||
client, | ||
chai, | ||
utils, | ||
options | ||
) => | ||
async function(expected) { | ||
const selector = utils.flag(this, 'object') | ||
const negate = utils.flag(this, 'negate') | ||
|
||
const elements = await client.$$(selector) | ||
if (!allowNone && !elements.length) { | ||
throw new chai.AssertionError( | ||
negate | ||
? `Expected <${selector}> to not be ${expectation} but no matching elements were found` | ||
: `Expected <${selector}> to be ${expectation} but no matching elements were found` | ||
) | ||
} | ||
|
||
const filteredList = (await Promise.all(elements.map(predicate))).filter( | ||
Boolean | ||
) | ||
|
||
this.assert( | ||
filteredList.length > 0, | ||
`Expected <${selector}> to be ${expectation} but it is not`, | ||
`Expected <${selector}> to not be ${expectation} but it is` | ||
) | ||
} | ||
|
||
export default booleanAssertion |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
import booleanAssertion from './booleanAssertion' | ||
|
||
export default booleanAssertion({ | ||
predicate: el => el.isExisting(), | ||
expectation: 'existing', | ||
allowNone: true, | ||
}) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
import booleanAssertion from './booleanAssertion' | ||
|
||
export default booleanAssertion({ | ||
predicate: el => el.isFocused(), | ||
expectation: 'focused', | ||
allowNone: false, | ||
}) |
Oops, something went wrong.