mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 17:46:46 +00:00
5b27bee3bd
## Description: Added possibility to use lowercase letters in clan name. See issue #876 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: theodoreleon.aetarax
127 lines
3.1 KiB
TypeScript
127 lines
3.1 KiB
TypeScript
import { PlayerInfo, PlayerType } from "../src/core/game/Game";
|
|
|
|
describe("PlayerInfo", () => {
|
|
describe("clan", () => {
|
|
test("should extract clan from name when format is [XX]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[CL]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("CL");
|
|
});
|
|
|
|
test("should extract clan from name when format is [XXX]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[ABC]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("ABC");
|
|
});
|
|
|
|
test("should extract clan from name when format is [XXXX]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[ABCD]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("ABCD");
|
|
});
|
|
|
|
test("should extract clan from name when format is [XXXXX]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[ABCDE]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("ABCDE");
|
|
});
|
|
|
|
test("should extract clan from name when format is [xxxxx]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[abcde]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("abcde");
|
|
});
|
|
|
|
test("should extract clan from name when format is [XxXxX]Name", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[AbCdE]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBe("AbCdE");
|
|
});
|
|
|
|
test("should return null when name doesn't start with [", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBeNull();
|
|
});
|
|
|
|
test("should return null when name doesn't contain ]", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[ABCPlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBeNull();
|
|
});
|
|
|
|
test("should return null when clan tag is not 2-5 uppercase letters", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[A]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBeNull();
|
|
});
|
|
|
|
test("should return null when clan tag contains non alphanumeric characters", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[A1c]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBeNull();
|
|
});
|
|
|
|
test("should return null when clan tag is too long", () => {
|
|
const playerInfo = new PlayerInfo(
|
|
"fr",
|
|
"[ABCDEF]PlayerName",
|
|
PlayerType.Human,
|
|
null,
|
|
"player_id",
|
|
);
|
|
expect(playerInfo.clan).toBeNull();
|
|
});
|
|
});
|
|
});
|