diff --git a/resources/maps/africa/manifest.json b/resources/maps/africa/manifest.json index c101cae4c..30e414b73 100644 --- a/resources/maps/africa/manifest.json +++ b/resources/maps/africa/manifest.json @@ -103,7 +103,7 @@ { "coordinates": [1094, 1093], "flag": "cd", - "name": "Democratic Republic of the Congo", + "name": "DR Congo", "strength": 2 }, { diff --git a/resources/maps/europe/manifest.json b/resources/maps/europe/manifest.json index cfd706e40..2cae0402a 100644 --- a/resources/maps/europe/manifest.json +++ b/resources/maps/europe/manifest.json @@ -169,7 +169,7 @@ { "coordinates": [517, 1483], "flag": "dz", - "name": "People's Democratic Republic of Algeria", + "name": "Algeria", "strength": 1 }, { diff --git a/resources/maps/gatewaytotheatlantic/manifest.json b/resources/maps/gatewaytotheatlantic/manifest.json index 45651537e..4a350e3fe 100644 --- a/resources/maps/gatewaytotheatlantic/manifest.json +++ b/resources/maps/gatewaytotheatlantic/manifest.json @@ -85,7 +85,7 @@ { "coordinates": [1609, 1837], "flag": "dz", - "name": "People's Republic of Algeria'", + "name": "Algeria", "strength": 2 }, { diff --git a/resources/maps/oceania/manifest.json b/resources/maps/oceania/manifest.json index ebbee416e..4fc8c2471 100644 --- a/resources/maps/oceania/manifest.json +++ b/resources/maps/oceania/manifest.json @@ -85,7 +85,7 @@ { "coordinates": [143, 37], "flag": "la", - "name": "Lao People's Democratic Republic", + "name": "Lao PDR", "strength": 1 }, { @@ -115,7 +115,7 @@ { "coordinates": [834, 215], "flag": "fm", - "name": "Federated States of Micronesia", + "name": "Micronesia", "strength": 1 }, { diff --git a/resources/maps/world/manifest.json b/resources/maps/world/manifest.json index c4aca9980..d5460fc5d 100644 --- a/resources/maps/world/manifest.json +++ b/resources/maps/world/manifest.json @@ -253,7 +253,7 @@ { "coordinates": [1074, 508], "flag": "cd", - "name": "The Democratic Republic of the Congo", + "name": "DR Congo", "strength": 1 }, { diff --git a/tests/NationNameLength.test.ts b/tests/NationNameLength.test.ts new file mode 100644 index 000000000..5bfc4960b --- /dev/null +++ b/tests/NationNameLength.test.ts @@ -0,0 +1,55 @@ +import fs from "fs"; +import { globSync } from "glob"; +import path from "path"; + +type Nation = { + name?: string; +}; + +type Manifest = { + nations?: Nation[]; +}; + +describe("Map manifests: nation name length constraint", () => { + test("All nations' names must be ≤ 27 characters", () => { + const manifestPaths = globSync( + path.resolve(process.cwd(), "resources/maps/**/manifest.json"), + ); + + expect(manifestPaths.length).toBeGreaterThan(0); + + const violations: string[] = []; + + for (const manifestPath of manifestPaths) { + try { + const raw = fs.readFileSync(manifestPath, "utf8"); + const manifest = JSON.parse(raw) as Manifest; + + (manifest.nations ?? []).forEach((nation, idx) => { + const name = nation?.name; + if (typeof name !== "string") { + violations.push( + `${manifestPath} -> nations[${idx}].name is not a string`, + ); + return; + } + if (name.length > 27) { + violations.push( + `${manifestPath} -> nations[${idx}].name "${name}" has length ${name.length} (> 27)`, + ); + } + }); + } catch (err) { + violations.push( + `Failed to parse ${manifestPath}: ${(err as Error).message}`, + ); + } + } + + if (violations.length > 0) { + throw new Error( + "Nation name length violations:\n" + violations.join("\n"), + ); + } + }); +});