Add partialDeepStrictEqual support - #7
Conversation
| else result = deepStrictEqualObject(a, b, memo) | ||
| if (partial === true && type.isArray()) { | ||
| result = partialDeepStrictEqualArray(a, b, partial, memo) | ||
| } else if (type.isError()) result = deepStrictEqualError(a, b, partial, memo) |
There was a problem hiding this comment.
If there is an error we fallback to deep strict?
I think that on node that would pass:
assert.partialDeepStrictEqual(new Error('x', { cause: 1 }), new Error('x'))
But I think that if we fallback to strict it would fail on this branch, maybe worth trying.
Note: Also, I know that taking node as an exemple is not Always the good approach haha.
There was a problem hiding this comment.
true, working on it.
| /should fail/ | ||
| ) | ||
| }) | ||
|
|
|
Adding more unit tests, I am converting the PR to draft for now. |
|
|
||
| for (const key of bKeys) { | ||
| // Do not test indexes when partial | ||
| if (partial === true && typeof key === 'string' && !isNaN(key)) continue |
There was a problem hiding this comment.
For this isNan() thing: do we want to skip when we have stuff like:
assert.partialDeepStrictEqual({ 0: 'a', 1: 'b' }, { 1: 'c' })
That should pass or fail?
| const itemA = a[j] | ||
|
|
||
| if (deepStrictEqualValue(itemA, itemB, memo)) { | ||
| if (deepStrictEqualValue(itemA, itemB, false, memo)) { |
There was a problem hiding this comment.
I would expect this:
| if (deepStrictEqualValue(itemA, itemB, false, memo)) { | |
| if (deepStrictEqualValue(itemA, itemB, partial, memo)) { |
There was a problem hiding this comment.
For instance, lets try:
assert.partialDeepStrictEqual(
new Set([{ a: 1, extra: 2 }]),
new Set([{ a: 1 }])
) There was a problem hiding this comment.
this comment and the above were real issues, I made a few tweaks
No description provided.