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
property assertion should only accept strings if nested, fixes #1043 #1044
Changes from 1 commit
e167009
3f2ce29
335fd33
5fd4fa2
8ff7cb7
a078a6d
e1442d0
d58d2bf
84062b1
f9e5a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1765,6 +1765,12 @@ module.exports = function (chai, _) { | |
, obj = flag(this, 'object') | ||
, ssfi = flag(this, 'ssfi'); | ||
|
||
if (typeof name !== 'string' && isNested) { | ||
var msgPrefix = flag(this, 'message') | ||
msgPrefix = msgPrefix ? msgPrefix + ': ' : '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here on line 1770 is repeated on lines 1769 and 1778 (except with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there is little duplication of logic here . We can remove msgPrefix and use flagMsg variable in its place and move the |
||
throw new AssertionError(msgPrefix + 'the argument to `property` must be a string') | ||
} | ||
|
||
if (isNested && isOwn) { | ||
flagMsg = flagMsg ? flagMsg + ': ' : ''; | ||
throw new AssertionError( | ||
|
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.
We don't need to define
msgPrefix
here; the value offlag(this, 'message')
is already stored in theflagMsg
variable from line 1764.