mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 18:23:31 +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:
31
libs/common/spec/matchers/to-contain-partial-objects.ts
Normal file
31
libs/common/spec/matchers/to-contain-partial-objects.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { EOL } from "os";
|
||||
|
||||
import { diff } from "jest-diff";
|
||||
|
||||
export const toContainPartialObjects: jest.CustomMatcher = function (
|
||||
received: Array<any>,
|
||||
expected: Array<any>,
|
||||
) {
|
||||
const matched = this.equals(
|
||||
received,
|
||||
expect.arrayContaining(expected.map((e) => expect.objectContaining(e))),
|
||||
);
|
||||
|
||||
if (matched) {
|
||||
return {
|
||||
message: () =>
|
||||
"Expected the received array NOT to include partial matches for all expected objects." +
|
||||
EOL +
|
||||
diff(expected, received),
|
||||
pass: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
message: () =>
|
||||
"Expected the received array to contain partial matches for all expected objects." +
|
||||
EOL +
|
||||
diff(expected, received),
|
||||
pass: false,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user