Skip to content

Commit c966e32

Browse files
committed
test(steam-id): adds test cases to test new and old steam id parsing
1 parent d982bf8 commit c966e32

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/steam_id.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { ok } from "assert";
2+
import { parse } from "../src";
3+
import { getEventString } from "./helpers/getEventString";
4+
import { counterTerroristTeam } from "./helpers/teams";
5+
6+
describe("steam id", () => {
7+
const event = {
8+
player: {
9+
kind: "player",
10+
entityId: 93,
11+
steamId: "76561198191236195",
12+
name: "PlayerName",
13+
team: counterTerroristTeam,
14+
},
15+
how: "world",
16+
};
17+
18+
it("should correctly parse with new steam id", () => {
19+
const log = '"PlayerName<93><[U:1:230970467]><CT>" [-1117 2465 -72] committed suicide with "world"';
20+
const result = parse(getEventString(log));
21+
22+
ok(result !== undefined, `Failed parse log: ${log}`);
23+
24+
expect(result.type).toBe("suicide");
25+
expect(result.payload).toMatchObject(event);
26+
});
27+
28+
it("should correctly parse with old steam id", () => {
29+
const log = '"PlayerName<93><STEAM_0:1:115485233><CT>" [-1117 2465 -72] committed suicide with "world"';
30+
const result = parse(getEventString(log));
31+
32+
ok(result !== undefined, `Failed parse log: ${log}`);
33+
34+
expect(result.type).toBe("suicide");
35+
expect(result.payload).toMatchObject(event);
36+
});
37+
});

0 commit comments

Comments
 (0)