-
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: add clickable, displayedInViewport, selected
- Loading branch information
1 parent
d234d07
commit a47781a
Showing
20 changed files
with
187 additions
and
326 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 @@ | ||
/** | ||
* 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.isClickable(), | ||
expectation: 'clickable', | ||
}) |
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.isDisplayedInViewport(), | ||
expectation: 'displayed in viewport', | ||
allowNone: true, | ||
}) |
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.isSelected(), | ||
expectation: 'selected', | ||
allowNone: false, | ||
}) |
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,86 @@ | ||
import chai, { expect } from 'chai' | ||
|
||
import { describe, beforeEach, afterEach, it } from 'mocha' | ||
import FakeClient from '../stubs/fake-client' | ||
import FakeElement from '../stubs/fake-element' | ||
import chaiWebdriverio from '../../src' | ||
import { upperFirst, lowerCase } from 'lodash' | ||
|
||
export const booleanAssertionTest = ({ | ||
method, | ||
expectation = lowerCase(method), | ||
allowNone, | ||
}) => | ||
describe(method, () => { | ||
let fakeClient | ||
let fakeElement1 | ||
|
||
beforeEach(() => { | ||
fakeClient = new FakeClient() | ||
fakeElement1 = new FakeElement() | ||
|
||
fakeElement1[`is${upperFirst(method)}`].resolves(false) | ||
fakeClient.$$.withArgs('.some-selector').resolves([fakeElement1]) | ||
fakeClient.$$.withArgs('.other-selector').resolves([]) | ||
|
||
chai.use(chaiWebdriverio(fakeClient)) | ||
}) | ||
|
||
afterEach(() => { | ||
fakeClient.__resetStubs__() | ||
fakeElement1.__resetStubs__() | ||
}) | ||
|
||
describe('When not negated', () => { | ||
it(`resolves when element is ${expectation}`, async function() { | ||
fakeElement1[`is${upperFirst(method)}`].resolves(true) | ||
await expect('.some-selector').to.be[method]() | ||
}) | ||
it(`rejects when element is not ${expectation}`, async function() { | ||
await expect('.some-selector') | ||
.to.be[method]() | ||
.to.be.rejectedWith( | ||
`Expected element <.some-selector> to be ${expectation} but it is not` | ||
) | ||
}) | ||
it(`rejects when element does not exist`, async function() { | ||
await expect('.other-selector') | ||
.to.be[method]() | ||
.to.be.rejectedWith( | ||
allowNone | ||
? `Expected element <.other-selector> to be ${expectation} but it is not` | ||
: `Expected element <.other-selector> to be ${expectation} but no matching elements were found` | ||
) | ||
}) | ||
}) | ||
describe('When negated', () => { | ||
it(`rejects when element is ${expectation}`, async function() { | ||
fakeElement1[`is${upperFirst(method)}`].resolves(true) | ||
await expect( | ||
expect('.some-selector') | ||
.not.to.be[method]() | ||
.then(null) | ||
).to.be.rejectedWith( | ||
`Expected element <.some-selector> to not be ${expectation} but it is` | ||
) | ||
}) | ||
it(`resolves when element is not ${expectation}`, async function() { | ||
await expect('.some-selector').not.to.be[method]() | ||
}) | ||
if (allowNone) { | ||
it(`resolves when element does not exist`, async function() { | ||
await expect(expect('.other-selector').not.to.be[method]()) | ||
}) | ||
} else { | ||
it(`rejects when element does not exist`, async function() { | ||
await expect( | ||
expect('.other-selector') | ||
.not.to.be[method]() | ||
.then(null) | ||
).to.be.rejectedWith( | ||
`Expected element <.other-selector> to not be ${expectation} but no matching elements were found` | ||
) | ||
}) | ||
} | ||
}) | ||
}) |
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,9 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
import { booleanAssertionTest } from './booleanAssertionTest' | ||
|
||
booleanAssertionTest({ method: 'clickable' }) |
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,9 @@ | ||
/** | ||
* NOTICE | ||
* This file has been modified from the source in | ||
* https://github.com/marcodejongh/chai-webdriverio | ||
*/ | ||
|
||
import { booleanAssertionTest } from './booleanAssertionTest' | ||
|
||
booleanAssertionTest({ method: 'displayedInViewport', allowNone: true }) |
Oops, something went wrong.