Skip to content

Commit 339452c

Browse files
committed
test: Move toBeIdenticalTo() matcher to CustomMatchersForTaskBuilder.ts
1 parent 1de4416 commit 339452c

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { TaskBuilder } from '../TestingTools/TaskBuilder';
2+
3+
declare global {
4+
namespace jest {
5+
interface Matchers<R> {
6+
toBeIdenticalTo(builder2: TaskBuilder): R;
7+
}
8+
9+
interface Expect {
10+
toBeIdenticalTo(builder2: TaskBuilder): any;
11+
}
12+
13+
interface InverseAsymmetricMatchers {
14+
toBeIdenticalTo(builder2: TaskBuilder): any;
15+
}
16+
}
17+
}
18+
19+
export function toBeIdenticalTo(builder1: TaskBuilder, builder2: TaskBuilder) {
20+
const task1 = builder1.build();
21+
const task2 = builder2.build();
22+
const pass = task1.identicalTo(task2);
23+
24+
if (pass) {
25+
return {
26+
message: () => 'Tasks treated as identical, but should be different',
27+
pass: true,
28+
};
29+
}
30+
return {
31+
message: () => {
32+
return 'Tasks should be identical, but are treated as different';
33+
},
34+
pass: false,
35+
};
36+
}

tests/CustomMatchers/jest.custom_matchers.setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import {
1313

1414
import { toSupportGroupingWithProperty } from './CustomMatchersForGrouping';
1515

16+
import { toBeIdenticalTo } from './CustomMatchersForTaskBuilder';
17+
expect.extend({
18+
toBeIdenticalTo,
19+
});
20+
1621
import { toMatchTaskDetails } from './CustomMatchersForTaskSerializer';
1722

1823
expect.extend({

tests/Task.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,45 +1171,6 @@ describe('order of recurring tasks', () => {
11711171
});
11721172
});
11731173

1174-
declare global {
1175-
namespace jest {
1176-
interface Matchers<R> {
1177-
toBeIdenticalTo(builder2: TaskBuilder): R;
1178-
}
1179-
1180-
interface Expect {
1181-
toBeIdenticalTo(builder2: TaskBuilder): any;
1182-
}
1183-
1184-
interface InverseAsymmetricMatchers {
1185-
toBeIdenticalTo(builder2: TaskBuilder): any;
1186-
}
1187-
}
1188-
}
1189-
1190-
export function toBeIdenticalTo(builder1: TaskBuilder, builder2: TaskBuilder) {
1191-
const task1 = builder1.build();
1192-
const task2 = builder2.build();
1193-
const pass = task1.identicalTo(task2);
1194-
1195-
if (pass) {
1196-
return {
1197-
message: () => 'Tasks treated as identical, but should be different',
1198-
pass: true,
1199-
};
1200-
}
1201-
return {
1202-
message: () => {
1203-
return 'Tasks should be identical, but are treated as different';
1204-
},
1205-
pass: false,
1206-
};
1207-
}
1208-
1209-
expect.extend({
1210-
toBeIdenticalTo,
1211-
});
1212-
12131174
describe('identicalTo', () => {
12141175
it('should check status', () => {
12151176
const lhs = new TaskBuilder().status(Status.TODO);

0 commit comments

Comments
 (0)