feat(drivers): country flag before the driver's name in timing, overlay, results, printouts and PDF (1.89.20)
This commit is contained in:
1 parent
da20a7e978
commit
6e45918e74
101 files changed
+2898
-45
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync } from "node:fs";
|
||||
import { COUNTRIES, countryCode, countryName, flagHtml, driverCountryCode } from "../src/country_flags.js";
|
||||
|
||||
test("a driver's country: name, English name, code or 3-letter code all give the flag", () => {
|
||||
for (const value of ["Sverige", "sweden", "SE", "SWE", " sverige "]) assert.equal(countryCode(value), "SE", value);
|
||||
assert.equal(countryCode("Norge"), "NO");
|
||||
assert.equal(countryCode("GBR"), "GB");
|
||||
assert.equal(countryName("NOR", "sv"), "Norge");
|
||||
assert.equal(countryName("NO", "en"), "Norway");
|
||||
});
|
||||
|
||||
test("no country, or an unknown one: no flag", () => {
|
||||
assert.equal(flagHtml(""), "");
|
||||
assert.equal(flagHtml("Atlantis"), "");
|
||||
assert.match(flagHtml("Sverige"), /<img class="country-flag" src="\/src\/flags\/se\.svg" alt="SE" title="Sverige"/);
|
||||
});
|
||||
|
||||
test("every country in the list has its flag file in the repo", () => {
|
||||
for (const [code] of COUNTRIES) assert.ok(existsSync(new URL(`../src/flags/${code.toLowerCase()}.svg`, import.meta.url)), code);
|
||||
});
|
||||
|
||||
test("the same person in another class: the country only has to be set once", () => {
|
||||
const drivers = [{ id: "a", profileId: "p", country: "Norge" }, { id: "b", profileId: "p", country: "" }, { id: "c", profileId: "q" }];
|
||||
assert.equal(driverCountryCode(drivers, "b"), "NO");
|
||||
assert.equal(driverCountryCode(drivers, "c"), "");
|
||||
assert.equal(driverCountryCode(drivers, "missing"), "");
|
||||
});
|
||||
Reference in new issue
Block a user