-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.spec.ts
55 lines (45 loc) · 1.46 KB
/
player.spec.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
import { Player } from "./modes/player";
import { Game } from "./game";
import { Tree } from "./tree";
import { machine } from "./machine";
import { Poker } from "./modes/poker";
describe('player', () => {
test('store', async () => {
machine.sTroughFull.state = true;
jest.spyOn(Poker, 'start').mockResolvedValue({} as any);
const game = await Game.start();
const player = game.curPlayer!;
const child1 = new class extends Tree {
bet = 2;
constructor() {
super();
player!.storeData<any>(this, ['bet']);
}
override get name(): string {
return 'Poker';
}
};
expect(player.store.Poker.bet).toBe(2);
expect(child1.bet).toBe(2);
child1.bet = 3;
expect(player.store.Poker.bet).toBe(3);
expect(child1.bet).toBe(3);
const child2 = new class extends Tree {
bet = 2;
constructor() {
super();
player.storeData<any>(this, ['bet']);
}
override get name(): string {
return 'Poker';
}
};
expect(player.store.Poker.bet).toBe(3);
expect(child1.bet).toBe(3);
expect(child2.bet).toBe(3);
child2.bet = 4;
expect(player.store.Poker.bet).toBe(4);
expect(child1.bet).toBe(4);
expect(child2.bet).toBe(4);
});
});