-
Notifications
You must be signed in to change notification settings - Fork 142
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
Compare dates when using td.matchers.contains #358
Comments
searls
added a commit
that referenced
this issue
Mar 31, 2018
Previously the comparison logic for traversable JS objects was separate (presumably to avoid cycles, but possibly also because it was a partial equality check, whereas the top-level contains() routine was a case-by-case assessment of whether something contained something else. This leads to confusing edge cases where something considered "contained" when inside a {} property would not be considered contained when passed to the top-level matcher. Whatever benefit this might have conferred was surely more confusing than it was worth. This only really required a change to one existing test-case, that is when whatever is passed to contains() happens to deeply equal whatever is actually passed, but that was never really a supported requirement, so I'm wary of judging this a breaking change, since intuitively it makes sense that the two things are in agreement. It could, however, throw some folks off when they're testing that something wraps something else in an additional array (in which case this would generate a false positive), though, and I don't have a good answer for that other than it's hard to divine someone's intent given how incredibly permissive this function's parameter signature is. Aside from handling the issue stated in #358, in which someone calling contains() and passing a {d: Date} would expect it to fail if the actual date differed from the passed one, this ch Fixes #358
searls
added a commit
that referenced
this issue
Mar 31, 2018
Previously the comparison logic for traversable JS objects was separate (presumably to avoid cycles, but possibly also because it was a partial equality check, whereas the top-level contains() routine was a case-by-case assessment of whether something contained something else. This leads to confusing edge cases where something considered "contained" when inside a {} property would not be considered contained when passed to the top-level matcher. Whatever benefit this might have conferred was surely more confusing than it was worth. This only really required a change to one existing test-case, that is when whatever is passed to contains() happens to deeply equal whatever is actually passed, but that was never really a supported requirement, so I'm wary of judging this a breaking change, since intuitively it makes sense that the two things are in agreement. It could, however, throw some folks off when they're testing that something wraps something else in an additional array (in which case this would generate a false positive), though, and I don't have a good answer for that other than it's hard to divine someone's intent given how incredibly permissive this function's parameter signature is. Aside from handling the issue stated in #358, in which someone calling contains() and passing a {d: Date} would expect it to fail if the actual date differed from the passed one, this ch Fixes #358
Good catch, totally legit bug, pain in the ass to fix. Landed in testdouble@3.7.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Testdouble.js does not seem to compare dates when using td.matchers.contains
Issue
Given the following code:
I expect the test to fail (dates are not the same), but the test passes:
https://runkit.com/bjarketrux/testdouble-js-matchers-contains-date/1.0.0
If I do not use contains then the test fails as expected:
https://runkit.com/bjarketrux/testdouble-js-matchers-contains-date/1.1.0
Environment
node 8.10.0
testdouble 3.5.2
The text was updated successfully, but these errors were encountered: