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

Adds regex support for CSS class assertions #451

Merged
merged 6 commits into from
Sep 5, 2019

Conversation

timiyay
Copy link
Contributor

@timiyay timiyay commented Aug 20, 2019

This PR adds RegExp support to the hasClass and doesNotHaveClass assertions, as suggested in #450.

Both functions now accept string|RegExp, in the same vein as hasText.

Each CSS class present on the target element will be matched against the RegExp, and:

  • for the positive hasClass assertion to return true, at least one CSS class must match; and
  • for the negative doesNotHaveClass assertion to return true, none of the CSS classes may match

Resolves #450

Timothy Asquith added 5 commits August 20, 2019 22:41
This is a preparatory step before adding regex support
This is a preparatory step before adding regex support
All CSS classes must not match. If any of them
match the assertion will return false.

The 'hasNoClass' and 'lacksClass' alias functions
now accept RegExp as well.
This update documents the newly-added
RegExp support within the 'hasClass'
and 'doesNotHaveClass' assertions.
lib/assertions.ts Outdated Show resolved Hide resolved
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.

nice work!! 👍

lib/assertions.ts Show resolved Hide resolved
lib/assertions.ts Show resolved Hide resolved
@Turbo87 Turbo87 changed the title feat: Adds regex support for CSS class assertions Adds regex support for CSS class assertions Aug 23, 2019
@timiyay
Copy link
Contributor Author

timiyay commented Aug 24, 2019

Thanks for the review @Turbo87 🙏

@timiyay
Copy link
Contributor Author

timiyay commented Aug 25, 2019

I've opened this PR ready to merge on an Aussie Monday morning, and realised I don't have merge permissions 😆

@Turbo87 Is the PR mergeable as-is, or can I help with any extra work to get it over the line?

@Turbo87
Copy link
Collaborator

Turbo87 commented Sep 5, 2019

whoops, sorry, forgot about this MR 🙈

@Turbo87 Turbo87 merged commit 732129b into mainmatter:master Sep 5, 2019
@timiyay timiyay deleted the feature/regex-class-assertions branch September 5, 2019 23:06
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.

Regex support for hasClass / doesNotHaveClass
2 participants