-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupJest.ts
More file actions
25 lines (22 loc) · 825 Bytes
/
setupJest.ts
File metadata and controls
25 lines (22 loc) · 825 Bytes
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
import SortableData from './src/domain/problems/sorting/SortableData';
expect.extend({
toBeSorted(received: SortableData) {
let lastValue = received.getElement(0).getValue();
for (let i = 1; i < received.getSize(); i++) {
if (received.getElement(i).getValue() < lastValue) {
return {
pass: false,
message: () =>
`Expected element ${i} to be greater than ${lastValue} but was ${received
.getElement(i)
.getValue()}`,
};
}
lastValue = received.getElement(i).getValue();
}
return {
pass: true,
message: () => 'SortableData elements are sorted correctly',
};
},
});