tobogganSe connecter

starfleet-ui

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

27 lignes · 804 octetsBrut · Historique
1import { expect, test } from 'bun:test';
2import { distance, fuelFor, jumpSeconds, tripSeconds, tripWear } from './rules';
3
4test('trip time follows the documented formula', () => {
5 // starting ship: speed 30; 90 units → 15 + 10*90/30 = 45 s
6 expect(tripSeconds(90, 30)).toBe(45);
7 expect(tripSeconds(0, 30)).toBe(15);
8});
9
10test('jump time: 60 s plus 1 s per 50 units', () => {
11 expect(jumpSeconds(500)).toBe(70);
12});
13
14test('fuel is a unit per 10 of distance, rounded up', () => {
15 expect(fuelFor(100)).toBe(10);
16 expect(fuelFor(101)).toBe(11);
17 expect(fuelFor(0)).toBe(0);
18});
19
20test('wear doubles in a nebula', () => {
21 expect(tripWear(100, false)).toBe(2);
22 expect(tripWear(100, true)).toBe(4);
23});
24
25test('distance is euclidean', () => {
26 expect(distance({ x: 0, y: 0 }, { x: 3, y: 4 })).toBe(5);
27});