1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-15 01:11:47 +01:00
bitwarden-browser/libs/common/spec/matchers/to-contain-partial-objects.spec.ts
Thomas Rittson 8c13ea894b
[PM-16917] Remove jest-extended dependency (#12798)
* add toContainPartialObjects matcher (replacing toIncludeAllPartialMembers from jest-extended)
* replace jest-extended matchers with equivalent default matchers
2025-01-15 10:43:26 -05:00

78 lines
1.5 KiB
TypeScript

describe("toContainPartialObjects", () => {
describe("matches", () => {
it("if the array only contains the partial objects", () => {
const actual = [
{
id: 1,
name: "foo",
},
{
id: 2,
name: "bar",
},
];
const expected = [{ id: 1 }, { id: 2 }];
expect(actual).toContainPartialObjects(expected);
});
it("if the array contains the partial objects and other objects", () => {
const actual = [
{
id: 1,
name: "foo",
},
{
id: 2,
name: "bar",
},
{
id: 3,
name: "baz",
},
];
const expected = [{ id: 1 }, { id: 2 }];
expect(actual).toContainPartialObjects(expected);
});
});
describe("doesn't match", () => {
it("if the array does not contain any partial objects", () => {
const actual = [
{
id: 1,
name: "foo",
},
{
id: 2,
name: "bar",
},
];
const expected = [{ id: 1, name: "Foo" }];
expect(actual).not.toContainPartialObjects(expected);
});
it("if the array contains some but not all partial objects", () => {
const actual = [
{
id: 1,
name: "foo",
},
{
id: 2,
name: "bar",
},
];
const expected = [{ id: 2 }, { id: 3 }];
expect(actual).not.toContainPartialObjects(expected);
});
});
});