Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 2x 2x 2x 4x 4x 4x 4x 4x 42x 42x 42x 4x 2x | import { expect } from "@jest/globals";
import type { MatcherFunction, SyncExpectationResult } from "expect";
import { receivedEqual } from "./receivedEqual";
import { ReceivedRow } from "../row/ReceivedRow";
const arrayEqual: MatcherFunction<[expected: { [index: string]: string }[]]> =
async function (actualUnknown: unknown, expected: { [index: string]: string }[]) {
const actual = actualUnknown as ReceivedRow[];
const messages: string[] = [];
let passed = true;
Iif (actual.length !== expected.length) {
passed = false;
messages.push("length = " + actual.length);
messages.push("length = " + expected.length);
}
for (let i = 0; i < actual.length; i++) {
const expectedValue = expected[i] as { [index: string]: string };
const result: SyncExpectationResult = await receivedEqual.call(this, actual[i], expectedValue);
Iif (!result.pass) {
passed = false;
messages.push("[" + i + "]");
messages.push(result.message());
}
}
return {
message: () => messages.join("\n"),
pass: passed
};
};
expect.extend({ arrayEqual, });
declare module "expect" {
interface Matchers<R> {
arrayEqual(expected: { [index: string]: string }[] ): R;
}
} |