40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import type { ElectionRun } from "@election2026/protocol";
|
|
import { describe, expect, it } from "vitest";
|
|
import { isPartyList, kind, mateLabel, place } from "../src/game/people/shared.ts";
|
|
|
|
const run = (over: Partial<ElectionRun> = {}): ElectionRun => ({
|
|
year: 2024,
|
|
date: "2024-01-13",
|
|
election: "總統",
|
|
office: "president",
|
|
indigenous: null,
|
|
county: "全國",
|
|
countyCode: null,
|
|
district: null,
|
|
number: 2,
|
|
party: "甲黨",
|
|
votes: 5_000_000,
|
|
share: 0.4,
|
|
elected: true,
|
|
incumbent: false,
|
|
...over,
|
|
});
|
|
|
|
describe("檔案室參選證的文字", () => {
|
|
it("總統副總統:選區寫全國,搭檔標明是總統還是副總統候選人", () => {
|
|
const top = run({ runningMate: "乙" });
|
|
const vice = run({ election: "副總統", runningMate: "甲" });
|
|
expect([place(top), kind(top), mateLabel(top)]).toEqual(["全國", "總統", "乙(副總統)"]);
|
|
expect([kind(vice), mateLabel(vice)]).toEqual(["副總統", "甲(總統)"]);
|
|
expect(mateLabel(run({ election: "直轄市長", office: "mayor" }))).toBeNull();
|
|
});
|
|
|
|
it("立委:區域寫縣市+選區,原住民附類別,不分區看名單排名", () => {
|
|
const district = run({ election: "立法委員", office: "legislator", county: "臺北市", countyCode: "63000", district: "第1選區" });
|
|
expect([place(district), kind(district), isPartyList(district)]).toEqual(["臺北市第1選區", "立法委員", false]);
|
|
expect(kind(run({ election: "立法委員", office: "legislator", indigenous: "山地原住民" }))).toBe("立法委員(山地原住民)");
|
|
const listed = run({ election: "不分區立法委員", office: "legislator", votes: null, share: null, listRank: 3, partyVotes: 4_000_000, partyShare: 0.3 });
|
|
expect([place(listed), isPartyList(listed)]).toEqual(["全國", true]);
|
|
});
|
|
});
|