-
Notifications
You must be signed in to change notification settings - Fork 16
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
Immutable actuals #16
Conversation
…mutable collection These tests currently fail. The result is some false positives!
c44a953
to
9cc8f0f
Compare
Oops. The problem is actually when only the expected value is an Immutable collection. Updated my commit messages and test descriptions. |
Hi @matthewwithanm, thanks for the contribution (and sorry for the delay, I was finally taking some vacations :-) ). |
Np. Yeah, I amended the commit. |
Ah right, thanks @matthewwithanm I am reviewing right now. |
@@ -71,7 +71,7 @@ module.exports = function (chai, utils) { | |||
return function (collection) { | |||
var obj = this._obj; | |||
|
|||
if (obj && obj instanceof Collection) { | |||
if (obj && obj instanceof Collection || collection instanceof Collection) { |
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.
@matthewwithanm, I'm not sure I see why we need this.
Currently:
expect([]).to.not.equal(List.of(1, 2, 3)); // Passes
expect([]).to.equal(List.of(1, 2, 3)); // Fails with "AssertionError: expected [] to equal List [ 1, 2, 3 ]"
which seems like what we should expect: if obj
is not a Collection
, the equality assertion is deferred to the original assertion.
Is there something I am I missing here?
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.
Hm, yeah it doesn't seem like we do…sorry, I can't remember anymore! I can remove it and see if we stumble on why again. Sound good?
Going to push a new PR…I think the real issue is that |
We're getting some false positives in our equals comparisons!
Turns out it's because
Immutable.is
is only used when the "actual" value is an Immutable collection. This fixes it.