| 1 |
|
| 2 |
import { expect, test } from "bun:test"; |
| 3 |
import { ENEMY, enemyColours, makeSides, PALETTE } from "../../static/engine/sides.js"; |
| 4 |
|
| 5 |
test("a body with no side wears today's enemy colours, and takes no slot", () => { |
| 6 |
const book = makeSides(); |
| 7 |
expect(enemyColours({}, book)).toBe(ENEMY); |
| 8 |
expect(ENEMY).toEqual({ skin: "#d8483f", dot: "#e35d5b", mark: "rgba(235,150,120,0.9)" }); |
| 9 |
expect(book.size).toBe(0); |
| 10 |
}); |
| 11 |
|
| 12 |
test("sides are handed the palette in the order they are first seen, and keep it", () => { |
| 13 |
const book = makeSides(); |
| 14 |
const a = enemyColours({ side: "a" }, book); |
| 15 |
const b = enemyColours({ side: "b" }, book); |
| 16 |
const c = enemyColours({ side: "c" }, book); |
| 17 |
expect([a, b, c]).toEqual([PALETTE[0], PALETTE[1], PALETTE[2]]); |
| 18 |
|
| 19 |
expect(a).toBe(ENEMY); |
| 20 |
expect(enemyColours({ side: "c" }, book)).toBe(c); |
| 21 |
expect(enemyColours({ side: "a" }, book)).toBe(a); |
| 22 |
}); |
| 23 |
|
| 24 |
test("the palette is all different, and none of it is a mate, the dead or you", () => { |
| 25 |
const all = PALETTE.flatMap((p) => [p.skin, p.dot]); |
| 26 |
expect(new Set(all).size).toBe(all.length); |
| 27 |
for (const taken of ["#3f9fd6", "#4fb3d9", "#eaeaea", "#555a63", "#4a4e57"]) expect(all).not.toContain(taken); |
| 28 |
}); |
| 29 |
|
| 30 |
test("more sides than colours wrap round rather than fail", () => { |
| 31 |
const book = makeSides(); |
| 32 |
for (let i = 0; i < PALETTE.length; i++) enemyColours({ side: `s${i}` }, book); |
| 33 |
expect(enemyColours({ side: "one more" }, book)).toBe(PALETTE[0]); |
| 34 |
}); |