-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add doesNotIncludeText()
assertion
#36
Conversation
lib/assertions.js
Outdated
|
||
let result = element.textContent.indexOf(text) === -1; | ||
let actual = element.textContent; | ||
let expected = text; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}"`
?
There was a problem hiding this comment.
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 });
?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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".
@Turbo87 Is there anything else that's needed for this to be merged? |
@Zureka my initial concern at #36 (comment) is still valid. QUnit will show something as "expected" that was actually not expected. |
lib/assertions.js
Outdated
} | ||
|
||
if (!message) { | ||
message = `Expected element ${this.targetDescription} to not include text "${text}"`; |
There was a problem hiding this comment.
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
lib/assertions.js
Outdated
let expected = `Element ${this.targetDescription} does not include text "${text}"`; | ||
let actual = expected; | ||
|
||
if(!result) { |
There was a problem hiding this comment.
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
doesNotIncludeText()
assertion
Thanks @Zureka! |
There appears to be a pattern of having a positive and a negative assertion for any given property/attribute. E.g.
isFocused
andisNotFocused
,hasAttribute
anddoesNotHaveAttribute
, andhasClass
anddoesNotHaveClass
.With that being said, it appears that there doesn't appear to be a corresponding inverse for the
includesText
assertion. Until now!