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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add 'visible' assertion for testing visibility !== hidden or collapse #29

Merged
merged 1 commit into from
Mar 13, 2018

Conversation

smhxx
Copy link
Contributor

@smhxx smhxx commented Jan 26, 2018

Hello!

This PR proposes/adds a new assertion to complement the .displayed assertion, which tests for the CSS property visibility being unequal to hidden or collapse.

I'm not really sure what to say about it other than that. 馃槀 I've been using chai-dom in a project of mine, and I was just surprised to see that there was no analog of .displayed to test whether elements were hidden using the visibility property. It's a pretty straightforward thing to add, since it follows pretty much the same "format" as .displayed, as far as code is concerned, so I figured I'd add it real quick and submit a PR.

Cheers!

Copy link
Owner

@nathanboktae nathanboktae left a comment

Choose a reason for hiding this comment

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

So when I originally started this based on chai-jquery, I very much did not want visibility to be here because it used jQuery's :visibile custom psudeoselector which was non-standard and very complex. I wanted to force people to write a different assertion. It's been 3 years now since then, so perhaps this is fine to add now. The implementation is sound and straight-forward, mapping directly and only to the CSS visibility selector.

})

it('passes when visible (any visibility value but hidden or collapse)', function() {
div.should.be.visible
Copy link
Owner

Choose a reason for hiding this comment

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

a div with visibility: visible may be nice, but this is probably fine.

@nathanboktae nathanboktae merged commit 1917781 into nathanboktae:master Mar 13, 2018
@smhxx smhxx deleted the assert-visible branch March 18, 2018 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants