Skip to content
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

fix(testing): support array values in assertObjectMatch #906

Merged
merged 5 commits into from
May 13, 2021
Merged

fix(testing): support array values in assertObjectMatch #906

merged 5 commits into from
May 13, 2021

Conversation

lowlighter
Copy link
Contributor

The filtered subset in assertObjectMatch is built with the following:

https://github.com/denoland/deno_std/blob/69183a05261b58870870b48e4191660b49212039/testing/asserts.ts#L502-L503

But because typeof [] === "object", array values match this condition and we end up with the following:

    {
-     foo: {
-       "0": 1,
-       "1": 2,
-       "2": 3,
-       length: 3,
-     },
+     foo: [
+       1,
+       2,
+       3,
+     ],
    }

This add a skip for arrays to get the wanted behaviour

testing/asserts_test.ts Outdated Show resolved Hide resolved
@lowlighter lowlighter requested a review from kt3k May 12, 2021 07:42
assertObjectMatch(i, {
foo: [
{ bar: false },
{ bar: { bar: { bar: { foo: true } } } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lowlighter Great! Thanks! LGTM

@kt3k kt3k merged commit 71b6522 into denoland:main May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants