Skip to content

Commit

Permalink
feat: add displayed to chai
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Oct 2, 2019
1 parent 0515b8b commit d301ec8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
13 changes: 13 additions & 0 deletions doc/chai.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ We added a few helpers to add additional context and reduce boilerplate. They tu
* [`.text`](#text)
* [`.value`](#value)
* [`.enabled`](#enabled)
* [`.displayed`](#displayed)
* [`.exist`](#exist)
* [`.elements`](#elements)

Expand Down Expand Up @@ -72,6 +73,18 @@ expect(await pageObject.isEnabled()).to.be.ok;
await expect(pageObject).enabled.to.eventually.be.ok;
```

### `.displayed`

```js
// before
expect(await pageObject.isDisplayed()).to.be.ok;
```

```js
// after
await expect(pageObject).displayed.to.eventually.be.ok;
```

### `.exist`

```js
Expand Down
6 changes: 6 additions & 0 deletions packages/chai/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const properties = {
pageObjectMethod: 'isEnabled',
pageObjectString: 'element',
},
displayed: {
type: 'addProperty',
PageObject: Element,
pageObjectMethod: 'isDisplayed',
pageObjectString: 'element',
},
exist: {
type: 'overwriteProperty',
PageObject: BaseElement,
Expand Down
4 changes: 2 additions & 2 deletions packages/chai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"sinon": "^7.3.2"
},
"peerDependencies": {
"@faltest/browser": "",
"@faltest/page-objects": ""
"@faltest/browser": ">=1.3.0",
"@faltest/page-objects": ">=1.7.0"
}
}
10 changes: 10 additions & 0 deletions packages/chai/test/integration/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ describe(function() {
fail: 'expected false to be truthy',
failNegated: 'expected true to be falsy',
},
displayed: {
PageObject: Element,
pageObjectMethod: 'isDisplayed',
actualPass: true,
actualFail: false,
append: expectTo => expectTo.be.ok,
pageObjectString: 'element',
fail: 'expected false to be truthy',
failNegated: 'expected true to be falsy',
},
exist: {
builtIn: Promise.resolve(true),
PageObject: BaseElement,
Expand Down

0 comments on commit d301ec8

Please sign in to comment.