This repository has been archived by the owner on Dec 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTests.js
61 lines (45 loc) · 1.57 KB
/
runTests.js
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
"use strict";
var logger = require('./logger.js');
const PlayerManager = require("./PlayerManager.js")
runTests();
function test(left, right, nb) {
var verbose = false;
var successful = (left === right);
if (verbose) {
logger.debug(`Test #${nb} ${successful} ${left} == ${right}`);
}
if (!successful) {
logger.warn(`Test #${nb} Result: ${left} != ${right}` );
}
return successful;
}
function runTests() {
const pm = require('./PlayerManager.js');
test(pm.exists(`doesn't exist ${Math.random()}`), false, 1);
var first_bullshit = pm.createPlayer("bullshit", "bullshit_name");
logger.debug(`Try to create another identical player. Should display a warning:`)
var second_bullshit = pm.createPlayer("bullshit", "bullshit_name");
test(pm.exists("bullshit"), true, 2);
test(first_bullshit, second_bullshit, 2.5);
test(pm.getPlayer("bullshit").name, "bullshit_name", 3);
test(pm.getPlayer("existe pas"), undefined, 4.5);
var p = pm.getOrCreatePlayer("new", "newName");
test(p.name, "newName", 5);
p = pm.getOrCreatePlayer("bullshit");
test(p.name, "bullshit_name", 6);
p.increaseLevel();
test(p.level, 2, 7);
test(p.allowedToPlay(), true, 8);
p.updateLastPlayed();
test(p.allowedToPlay(), false, 9);
test(p.relight, undefined, 10);
p.increaseRelightCount();
test(p.relight, 1, 11);
test( pm.isAdmin("bullshit"), false, 12);
test( pm.isAdmin("214590808727355393"), true, 13);
pm.writeDBFile();
logger.debug(`Try to double write. Should display a warning:`)
pm.writeDBFile();
logger.debug(`All tests completed. Est-ce que y'avait des warnings?`);
// pm.exit()
}