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: expect toMatchObject should properly handle arrays #4

Merged
merged 1 commit into from
Oct 28, 2021

Conversation

ValeriaVG
Copy link
Owner

The following tests are now passing:

it("toMatchObject/arrays", () => {
  expect([]).toMatchObject([]);
  expect([]).not.toMatchObject({});
  expect([1, 2, 3]).toMatchObject([1, 2]);
  expect([2, 3]).not.toMatchObject([1, 2, 3]);
  expect([{ id: 1, name: "1" }, { id: 2, name: "2" }, { id: 3 }]).toMatchObject(
    [{ id: 1 }, { id: 2 }, { id: 3 }]
  );
  expect([{ id: 1 }, { id: 2 }, { id: 3 }]).not.toMatchObject([
    { id: 1, name: "1" },
    { id: 2, name: "2" },
    { id: 3 },
  ]);
  expect({ a: [1, 2, 3] }).toMatchObject({ a: [1, 2, 3] });
  expect({ a: [1, 2] }).not.toMatchObject({ a: [1, 2, 3] });
});

@ValeriaVG ValeriaVG merged commit c789755 into master Oct 28, 2021
@ValeriaVG ValeriaVG deleted the fix/expect-match-object branch October 28, 2021 18:12
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.

1 participant