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 doesNotIncludeText() assertion #36

Merged
merged 7 commits into from
Nov 7, 2017

Conversation

Zureka
Copy link

@Zureka Zureka commented Nov 3, 2017

There appears to be a pattern of having a positive and a negative assertion for any given property/attribute. E.g. isFocused and isNotFocused, hasAttribute and doesNotHaveAttribute, and hasClass and doesNotHaveClass.

With that being said, it appears that there doesn't appear to be a corresponding inverse for the includesText assertion. Until now!


let result = element.textContent.indexOf(text) === -1;
let actual = element.textContent;
let expected = text;
Copy link
Collaborator

Choose a reason for hiding this comment

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

expected = text does not make sense in this case, right?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch! Would you prefer the name unexpected or something else?

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe something like `does not include "${text}"`?

Copy link
Author

Choose a reason for hiding this comment

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

I can certainly update the phrasing of the message to does not include "${text}", my question is actually regarding what is passed into this.pushResult at the end of this function. Would it be fine to say this.pushResult({ results, actual, unexpected, message });?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no, because the pushResult method explicitly requires an expected attribute (see api.qunitjs.com/assert/pushResult)

Copy link
Author

Choose a reason for hiding this comment

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

That's what I figured. this.pushResult({ result, actual, expected: unexpected, message}); would work but seems a little ironic to "expect the unexpected".

@Zureka
Copy link
Author

Zureka commented Nov 7, 2017

@Turbo87 Is there anything else that's needed for this to be merged?

@Turbo87
Copy link
Collaborator

Turbo87 commented Nov 7, 2017

@Zureka my initial concern at #36 (comment) is still valid. QUnit will show something as "expected" that was actually not expected.

}

if (!message) {
message = `Expected element ${this.targetDescription} to not include text "${text}"`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can message = expected here like in a few of the other assertions

let expected = `Element ${this.targetDescription} does not include text "${text}"`;
let actual = expected;

if(!result) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is a space missing here after the if

@Turbo87 Turbo87 changed the title Feature/does not include text Add doesNotIncludeText() assertion Nov 7, 2017
@Turbo87 Turbo87 merged commit 9402535 into mainmatter:master Nov 7, 2017
@Turbo87
Copy link
Collaborator

Turbo87 commented Nov 7, 2017

Thanks @Zureka!

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