Skip to content
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

Merged
merged 6 commits into from
Mar 26, 2018

Conversation

scalvert
Copy link
Collaborator

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."

@patocallaghan
Copy link
Contributor

Great work @scalvert 👏 apologies I couldn’t complete my PR sooner.

@scalvert
Copy link
Collaborator Author

scalvert commented Mar 24, 2018

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.

Copy link
Collaborator

@Turbo87 Turbo87 left a 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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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? 😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Absolutely.

Copy link
Collaborator Author

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()', () => {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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"
Copy link
Collaborator

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 🤔

Copy link
Collaborator Author

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.

Copy link
Collaborator

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@Turbo87 Turbo87 merged commit b5eb158 into mainmatter:master Mar 26, 2018
@patocallaghan
Copy link
Contributor

Thanks @Turbo87 and @scalvert! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants