2022-03-28 16:00:42 +02:00
|
|
|
import { webcrypto } from "crypto";
|
|
|
|
|
2023-09-28 20:47:02 +02:00
|
|
|
import { toEmit, toEmitValue, toEqualBuffer } from "./spec";
|
2022-07-26 03:40:32 +02:00
|
|
|
|
2022-03-28 16:00:42 +02:00
|
|
|
Object.defineProperty(window, "crypto", {
|
|
|
|
value: webcrypto,
|
|
|
|
});
|
2022-07-26 03:40:32 +02:00
|
|
|
|
|
|
|
// Add custom matchers
|
|
|
|
|
|
|
|
expect.extend({
|
|
|
|
toEqualBuffer: toEqualBuffer,
|
2023-09-28 20:47:02 +02:00
|
|
|
toEmit: toEmit,
|
|
|
|
toEmitValue: toEmitValue,
|
2022-07-26 03:40:32 +02:00
|
|
|
});
|
|
|
|
|
2023-08-04 04:13:33 +02:00
|
|
|
export interface CustomMatchers<R = unknown> {
|
2022-07-26 03:40:32 +02:00
|
|
|
toEqualBuffer(expected: Uint8Array | ArrayBuffer): R;
|
2023-09-28 20:47:02 +02:00
|
|
|
toEmit(timeoutMs?: number): R;
|
|
|
|
toEmitValue(
|
|
|
|
expected: unknown,
|
|
|
|
comparer?: (a: unknown, b: unknown) => boolean,
|
|
|
|
timeoutMs?: number
|
|
|
|
): R;
|
2022-07-26 03:40:32 +02:00
|
|
|
}
|