[ui] PlanetGarden: Her round planet, the player's gardener, the ring of care, and care by gesture
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fc from 'fast-check';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { invitation, nextInvitation, nextSunEvent, sunDay, type Place, type SunDay } from '../src/sun/sun.js';
|
||||
import { invitation, lightAt, nextInvitation, nextSunEvent, sunDay, type Place, type SunDay } from '../src/sun/sun.js';
|
||||
import { addDays, localDay } from '../src/time/localDay.js';
|
||||
|
||||
/** Recorded by scripts/fetch-sun-golden.ts from the U.S. Naval Observatory. */
|
||||
@@ -317,3 +317,27 @@ describe('nextSunEvent — the next thing to look up for (sunrise.md)', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('lightAt — the sky over her planet (planet-garden.md)', () => {
|
||||
const brno: Place = { lat: 49.1951, lon: 16.6068, timeZone: 'Europe/Prague' };
|
||||
const day = sunDay('2026-03-02', brno);
|
||||
if (day.kind !== 'sun-sets') throw new Error('Brno has a sunset in March');
|
||||
|
||||
it('night before dawn, golden at sunrise, day at noon, golden at sunset, night after', () => {
|
||||
expect(lightAt(day.sunrise - 2 * HOUR, brno)).toBe('night');
|
||||
expect(lightAt(day.sunrise, brno)).toBe('golden');
|
||||
expect(lightAt(day.solarNoon, brno)).toBe('day');
|
||||
expect(lightAt(day.sunset - 30 * MINUTE, brno)).toBe('golden');
|
||||
expect(lightAt(day.sunset + 2 * HOUR, brno)).toBe('night');
|
||||
});
|
||||
|
||||
it('polar day is day, golden around the lowest light; polar night is night, golden at noon', () => {
|
||||
const tromso: Place = { lat: 69.6492, lon: 18.9553, timeZone: 'Europe/Oslo' };
|
||||
const summer = sunDay('2026-06-21', tromso);
|
||||
const winter = sunDay('2026-12-21', tromso);
|
||||
if (summer.kind !== 'polar-day' || winter.kind !== 'polar-night') throw new Error('Tromsø: polar day and night');
|
||||
expect(lightAt(summer.solarNoon, tromso)).toBe('day');
|
||||
expect(lightAt(winter.solarNoon, tromso)).toBe('golden');
|
||||
expect(lightAt(winter.solarNoon + 4 * HOUR, tromso)).toBe('night');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user