mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:30:43 +00:00
1049b7e7dc
## Description: Properly split out clantags and usernames, a clantag should not be part of a username. <img width="285" height="286" alt="image" src="https://github.com/user-attachments/assets/8ac56e82-b12c-4fc0-9774-e445252a6e61" /> https://api.openfront.dev/game/ojkqZFb2 <img width="296" height="596" alt="image" src="https://github.com/user-attachments/assets/85152f80-c111-4f87-b85b-8516c9c6137b" /> https://api.openfront.dev/game/MF32BkVc requires; https://github.com/openfrontio/infra/pull/264 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n
100 lines
2.4 KiB
TypeScript
100 lines
2.4 KiB
TypeScript
import { PlayerInfo, PlayerType } from "../src/core/game/Game";
|
|
|
|
describe("PlayerInfo", () => {
|
|
describe("clanTag from explicit clanTag parameter", () => {
|
|
test("should set clanTag from clanTag parameter", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
"abc",
|
|
);
|
|
expect(playerInfo.clanTag).toBe("abc");
|
|
});
|
|
|
|
test("should preserve already-uppercase clan tag", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
"CLAN",
|
|
);
|
|
expect(playerInfo.clanTag).toBe("CLAN");
|
|
});
|
|
|
|
test("should set clan to null when clanTag is not provided", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clanTag).toBeNull();
|
|
});
|
|
|
|
test("should set clan to null when clanTag is null", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
null,
|
|
);
|
|
expect(playerInfo.clanTag).toBeNull();
|
|
});
|
|
|
|
test("should set clan to null when clanTag is undefined", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
undefined,
|
|
);
|
|
expect(playerInfo.clanTag).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("displayName", () => {
|
|
test("should construct display name with clan tag", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
"CLAN",
|
|
);
|
|
expect(playerInfo.displayName).toBe("[CLAN] PlayerName");
|
|
});
|
|
|
|
test("should return just name when no clan tag", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.displayName).toBe("PlayerName");
|
|
});
|
|
|
|
test("should preserve clan tag casing in display name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
false,
|
|
"abc",
|
|
);
|
|
expect(playerInfo.displayName).toBe("[abc] PlayerName");
|
|
});
|
|
});
|
|
});
|