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

Implement "not to have (class|classes)" assertion. #269

Merged
merged 4 commits into from
Jun 7, 2019

Conversation

alexjeffburke
Copy link
Member

No description provided.

@coveralls
Copy link

coveralls commented Jun 6, 2019

Pull Request Test Coverage Report for Build 1134

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 93.463%

Totals Coverage Status
Change from base Build 1126: 0.06%
Covered Lines: 654
Relevant Lines: 683

💛 - Coveralls

src/index.js Outdated
removeValueFromArray(expectedClasses, namedValue)
);

return expect(subject, 'to only have classes', expectedClasses);
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, couldn't you map it to:

const classAttributeValue = getAttributes(subject).class;
const actualClasses = typeof classAttributeValue === 'string' ? getClassNamesFromAttributeValue(classAttributeValue) : [];
const expectedClasses = Array.isArray(value) ? value : [value];
expect(actualClasses, 'not to contain', ...expectedClasses);

That would produce a nicer error message and could also cover the to have classes case with a bit of flag forwarding?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah could do - IIRC I did it this way for consistency something else in U-dom, I think it was https://github.com/unexpectedjs/unexpected-dom/blob/master/src/index.js#L1329. But happy to change it round if that works better :)

Copy link
Member

Choose a reason for hiding this comment

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

When I looked at the test I thought it was confusing that it said:

class="bar quux" // expected [ 'bar', 'quux' ] to equal [ 'bar' ]

... when the user didn't actually mention bar in the assertion.

If the other place is equivalent to that, I think we should change that as well 🤗

Copy link
Member Author

Choose a reason for hiding this comment

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

Have pushed a commit to make the assertion run via "not to contain" :)

Copy link
Member

Choose a reason for hiding this comment

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

Yay, thanks! 🎉

Copy link
Member

@papandreou papandreou left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

src/index.js Outdated
@@ -99,6 +99,14 @@ function validateStyles(expect, str) {
}
}

function removeValueFromArray(array, value) {
Copy link
Member

Choose a reason for hiding this comment

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

Can be removed now

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh! Knew I left something - thanks!

Copy link
Member

@sunesimonsen sunesimonsen left a comment

Choose a reason for hiding this comment

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

👍

@sunesimonsen
Copy link
Member

sunesimonsen commented Jun 7, 2019

Don't we need docs?

@alexjeffburke
Copy link
Member Author

@sunesimonsen you were absolutely right and that should have been in there :)

@alexjeffburke
Copy link
Member Author

alexjeffburke commented Jun 7, 2019

Closes #201

Copy link
Member

@sunesimonsen sunesimonsen left a comment

Choose a reason for hiding this comment

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

👍 great thanks

@alexjeffburke alexjeffburke merged commit ef899ba into master Jun 7, 2019
@alexjeffburke alexjeffburke deleted the feature/not-to-have-class branch December 23, 2019 15:01
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.

4 participants