starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | import { expect, test } from 'bun:test'; |
| 2 | import { frameGalaxy, galaxyPos } from './coords'; |
| 3 | |
| 4 | test('galaxyPos maps game y to scene -z at galaxy scale', () => { |
| 5 | expect(galaxyPos({ x: 400, y: 200 })).toEqual([100, 0, -50]); |
| 6 | }); |
| 7 | |
| 8 | test('frameGalaxy looks at the middle of the systems, from above and in front', () => { |
| 9 | const { pos, look } = frameGalaxy([ |
| 10 | { x: 0, y: 0 }, |
| 11 | { x: 800, y: 400 } |
| 12 | ]); |
| 13 | // bounds in scene units: x 0..200, z -100..0 → centre (100, -50), extent 200 |
| 14 | expect(look).toEqual([130, 0, -50]); |
| 15 | expect(pos[0]).toBe(130); |
| 16 | expect(pos[1]).toBeGreaterThan(200); |
| 17 | expect(pos[2]).toBeGreaterThan(-50); |
| 18 | }); |
| 19 | |
| 20 | test('frameGalaxy has a sensible default for an empty galaxy', () => { |
| 21 | expect(frameGalaxy([]).look).toEqual([0, 0, 0]); |
| 22 | }); |