forked from sismo-core/sismo-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.ts
58 lines (55 loc) · 1.96 KB
/
jest.setup.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Group, GroupWithData, groupMetadata } from "./src/topics/group";
import { groupSnapshotMetadata } from "topics/group-snapshot/group-snapshot";
import { GroupSnapshot, GroupSnapshotWithData } from "topics/group-snapshot/group-snapshot.types";
jest.setTimeout(30000);
process.setMaxListeners(20);
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<R> {
toBeSameGroup(expected: Group | GroupWithData): CustomMatcherResult;
toContainGroup(expected: Group | GroupWithData): CustomMatcherResult;
toBeSameGroupSnapshot(expected: GroupSnapshot | GroupSnapshotWithData): CustomMatcherResult;
toContainGroupSnapshot(expected: GroupSnapshot | GroupSnapshotWithData): CustomMatcherResult;
}
}
}
expect.extend({
toBeSameGroup(received: Group | GroupWithData, group: Group | GroupWithData) {
expect(groupMetadata(received)).toEqual(groupMetadata(group));
return {
pass: true,
message: () => "",
};
},
toContainGroup(received: (Group | GroupWithData)[], group: Group | GroupWithData) {
expect(received.map((group) => groupMetadata(group))).toContainEqual(groupMetadata(group));
return {
pass: true,
message: () => "",
};
},
toBeSameGroupSnapshot(
received: GroupSnapshot | GroupSnapshotWithData,
groupSnapshot: GroupSnapshot | GroupSnapshotWithData
) {
expect(groupSnapshotMetadata(received)).toEqual(groupSnapshotMetadata(groupSnapshot));
return {
pass: true,
message: () => "",
};
},
toContainGroupSnapshot(
received: (GroupSnapshot | GroupSnapshotWithData)[],
groupSnapshot: GroupSnapshot | GroupSnapshotWithData
) {
expect(received.map((groupSnapshot) => groupSnapshotMetadata(groupSnapshot))).toContainEqual(
groupSnapshotMetadata(groupSnapshot)
);
return {
pass: true,
message: () => "",
};
},
});