-
Notifications
You must be signed in to change notification settings - Fork 3
/
setupTests.ts
46 lines (45 loc) · 1.38 KB
/
setupTests.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
import { RawMessage } from "@minecraft/server";
import { LogLevel, Logger } from "./src/Logging";
jest.mock('@minecraft/server', () => {
return {
Direction: {
Down: 'Down',
East: 'East',
North: 'North',
South: 'South',
Up: 'Up',
West: 'West',
},
system: {
afterEvents: {
scriptEventReceive: {
subscribe: jest.fn(),
}
},
clearRun: (id:number) => {
clearInterval(id);
clearTimeout(id);
},
run: (callback: () => void) => {
return setTimeout(callback, 50);
},
runInterval: (callback: () => void, tickInterval?: number): number => {
return setInterval(callback, tickInterval || 1)[Symbol.toPrimitive]();
},
runTimeout: (callback: () => void, tickDelay?: number): number => {
return setTimeout(callback, tickDelay || 1)[Symbol.toPrimitive]();
},
},
world: {
sendMessage: (message: (RawMessage | string)[] | RawMessage | string): void => {
console.log(message);
}
}
};
}, { virtual: true });
Logger.getOutputConfig()[LogLevel.Trace.level] = [];
Logger.getOutputConfig()[LogLevel.Debug.level] = [];
Logger.getOutputConfig()[LogLevel.Info.level] = [];
Logger.getOutputConfig()[LogLevel.Warn.level] = [];
Logger.getOutputConfig()[LogLevel.Error.level] = [];
Logger.getOutputConfig()[LogLevel.Fatal.level] = [];