mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-26 12:25:20 +01:00
28de9439be
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
32 lines
848 B
TypeScript
32 lines
848 B
TypeScript
/**
|
|
* The inbuilt toEqual() matcher will always return TRUE when provided with 2 ArrayBuffers.
|
|
* This is because an ArrayBuffer must be wrapped in a new Uint8Array to be accessible.
|
|
* This custom matcher will automatically instantiate a new Uint8Array on the received value
|
|
* (and optionally, the expected value) and then call toEqual() on the resulting Uint8Arrays.
|
|
*/
|
|
export const toEqualBuffer: jest.CustomMatcher = function (
|
|
received: ArrayBuffer | Uint8Array,
|
|
expected: ArrayBuffer | Uint8Array,
|
|
) {
|
|
received = new Uint8Array(received);
|
|
expected = new Uint8Array(expected);
|
|
|
|
if (this.equals(received, expected)) {
|
|
return {
|
|
message: () => `expected
|
|
${received}
|
|
not to match
|
|
${expected}`,
|
|
pass: true,
|
|
};
|
|
}
|
|
|
|
return {
|
|
message: () => `expected
|
|
${received}
|
|
to match
|
|
${expected}`,
|
|
pass: false,
|
|
};
|
|
};
|