mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-16917] Remove jest-extended dependency (#12798)
* add toContainPartialObjects matcher (replacing toIncludeAllPartialMembers from jest-extended) * replace jest-extended matchers with equivalent default matchers
This commit is contained in:
77
libs/common/spec/matchers/to-contain-partial-objects.spec.ts
Normal file
77
libs/common/spec/matchers/to-contain-partial-objects.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user