-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isVisible and isNotVisible assertion helpers #67
Conversation
Great work @scalvert 👏 apologies I couldn’t complete my PR sooner. |
No worries, @patocallaghan! We're all in this together :) Thanks for getting a start on this. It's super useful. Do you want to close the other PR in favor of this? This PR contains your prior commits too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for working on this @patocallaghan and @scalvert!
|
||
- is the element's offsetWidth non-zero | ||
- is the element's offsetHeight non-zero | ||
- is the length of an element's DOMRect objects found via getClientRects() non-zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to clarify, this means it's visible on the page, but not necessarily that it's within the currently rendered viewport, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's exactly what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, can we add that to the docs so that they read a little easier? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Absolutely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
import TestAssertions from '../helpers/test-assertions'; | ||
|
||
describe('assert.dom(...).isVisible()', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a comment here explaining why this is difficult to test in the jsdom-based testing system and possibly a reference to the Ember-based tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that for sure.
package.json
Outdated
@@ -25,7 +25,8 @@ | |||
"test": "jest", | |||
"test:coverage": "jest --coverage", | |||
"test:ember": "ember test", | |||
"test:watch": "jest --watchAll --notify" | |||
"test:watch": "jest --watchAll --notify", | |||
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unrelated to the PR 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is :). I'll remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
This PR supersedes #54 and is a continuation of Pat's work. I'm just trying to help push this in as I find it to be a very useful feature.
From @patocallaghan's PR:
"Fixes #52
Adds isVisible and isNotVisible assertion helpers.
Visibility is modelled off of jQuery's :visible logic in jQuery 3.0 https://github.com/jquery/jquery/blob/4a2bcc27f9c3ee24b3effac0fbe1285d1ee23cc5/src/css/hiddenVisibleSelectors.js#L11-L13
As mentioned in the issue you may decide not to merge this. If you do, I can then update the README information."