-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glicko2.test.ts
96 lines (70 loc) · 2.24 KB
/
glicko2.test.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { Glicko2, Player, Race } from "./glicko2";
describe("Glicko2 Class", () => {
test("Is Glicko2 an object when initialized", () => {
expect(typeof new Glicko2()).toBe("object");
});
test("Create player", () => {
const Glicko = new Glicko2();
const player = Glicko.makePlayer();
expect(Glicko.players_index).toBe(1);
expect(JSON.stringify(Glicko.getPlayers())).toBe(
JSON.stringify({
"0": player,
})
);
});
test.todo("Add match");
test.todo("Update ratings");
test.todo("Make race");
test.todo("Remove players");
test.todo("Clean previous matches");
test.todo("Calculate player ratings");
test.todo("Add result");
test.todo("Create internal player when id is defined");
});
describe("Player class", () => {
test("Is Player an object when initialized", () => {
expect(typeof new Player(1, 1, 1, 1)).toBe("object");
});
test.todo("Update rank");
test.todo("Get rating");
test.todo("Get RD");
test.todo("Set RD");
test.todo("Get vol");
test.todo("Set vol");
test.todo("Get Ratings");
test.todo("Add result");
test.todo("Has played");
test.todo("Old procedure");
test.todo("new procedure mod");
test.todo("Old procedure simple");
});
describe("Race class", () => {
const player1 = new Player(1500, 350, 0.06, 0.5);
const player2 = new Player(1500, 350, 0.06, 0.5);
const player3 = new Player(1500, 350, 0.06, 0.5);
test("Create a race with no equal result", () => {
expect(
JSON.stringify(new Race([[player1], [player2], [player3]]).matches)
).toBe(
JSON.stringify([
[player1, player2, 1],
[player1, player3, 1],
[player2, player3, 1],
])
);
});
test("Create a race with players with equal result", () => {
expect(
JSON.stringify(
new Race([[player1], [player2, player3]]).getMatches()
)
).toBe(
JSON.stringify([
[player1, player2, 1],
[player1, player3, 1],
[player2, player3, 0.5],
])
);
});
});