21 lines
816 B
TypeScript
21 lines
816 B
TypeScript
import { expect, test } from "bun:test"
|
|
import { MOB_KINDS, Mob } from "../game/actors/Mob"
|
|
|
|
// The mob SAB packs a kind as its index in MOB_KINDS; the main thread and every
|
|
// render worker must agree on that order. Freeze it here: appending a kind is fine,
|
|
// but reordering or removing an existing one silently corrupts which mesh/texture a
|
|
// worker draws.
|
|
test("MOB_KINDS order is frozen (mob SAB ids)", () => {
|
|
expect(MOB_KINDS).toEqual(["frog", "bee", "robin"])
|
|
})
|
|
|
|
test("every kind resolves to a complete definition", () => {
|
|
for (const kind of MOB_KINDS) {
|
|
const d = Mob.def(kind)
|
|
expect(d.name).toBe(kind)
|
|
expect(typeof d.build).toBe("function")
|
|
expect(typeof d.update).toBe("function")
|
|
expect(d.boundingRadius).toBeGreaterThan(0)
|
|
expect(d.bodyHeight).toBeGreaterThan(0)
|
|
}
|
|
})
|