{en.sunset.noTown}
{/if} diff --git a/packages/ui/src/sunset/SunsetLine.svelte b/packages/ui/src/sunset/SunsetLine.svelte index b0cdd88..b0405d4 100644 --- a/packages/ui/src/sunset/SunsetLine.svelte +++ b/packages/ui/src/sunset/SunsetLine.svelte @@ -1,26 +1,36 @@ diff --git a/packages/ui/test/chair-sunset.test.ts b/packages/ui/test/chair-sunset.test.ts index 288cdd8..cc344fd 100644 --- a/packages/ui/test/chair-sunset.test.ts +++ b/packages/ui/test/chair-sunset.test.ts @@ -91,6 +91,14 @@ describe('the in-game sunset (chair-sunset.md)', () => { expect(screen.queryByRole('dialog')).toBeNull(); }); + it('late in the evening its words still name the real sunset, never the sunrise (sunrise.md R4)', async () => { + const late = Date.parse('2026-03-29T22:00:00+02:00'); + const scene = await openScene({ now: () => late }); + vi.advanceTimersByTime(SUNSET_MS); + await tick(); + expect(within(scene).getByText(/^Tomorrow the sun sets at .* in Brno\.$/)).toBeTruthy(); + }); + it('with no town and no guess, the words after it ask for a town', async () => { const scene = await openScene({ guess: null, load: async () => ({ kind: 'device-zone' }) }); vi.advanceTimersByTime(SUNSET_MS); diff --git a/packages/ui/test/sunset.test.ts b/packages/ui/test/sunset.test.ts index 08ef00a..91213c6 100644 --- a/packages/ui/test/sunset.test.ts +++ b/packages/ui/test/sunset.test.ts @@ -89,11 +89,23 @@ describe('the garden remembers', () => { expect(screen.queryByRole('searchbox')).toBeNull(); }); - it('after the sunset, it speaks of tomorrow\'s', async () => { + it("after the sunset, it names tomorrow's sunrise (sunrise.md)", async () => { const after = invitation(sunDay('2026-03-29', brno)) + 60_000; render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => after }) }); - const tomorrow = invitation(sunDay('2026-03-30', brno)); - expect(await screen.findByText(en.sunset.tomorrow(timeOf(brno, tomorrow), 'Brno'))).toBeTruthy(); + const tomorrow = sunDay('2026-03-30', brno); + if (tomorrow.kind !== 'sun-sets') throw new Error('Brno has a sunrise in March'); + expect(await screen.findByText(en.sunset.risesTomorrow(timeOf(brno, tomorrow.sunrise), 'Brno'))).toBeTruthy(); + }); + + it('before sunrise, it names this morning\'s sunrise; after it, tonight\'s sunset', async () => { + const early = Date.parse('2026-03-29T04:00:00+02:00'); + const today = sunDay('2026-03-29', brno); + if (today.kind !== 'sun-sets') throw new Error('Brno has a sunrise in March'); + render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => early }) }); + expect(await screen.findByText(en.sunset.rises(timeOf(brno, today.sunrise), 'Brno'))).toBeTruthy(); + cleanup(); + render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => today.sunrise + 60_000 }) }); + expect(await screen.findByText(en.sunset.tonight(timeOf(brno, today.sunset), 'Brno'))).toBeTruthy(); }); it('in polar night it speaks of the noon twilight; in polar day, of the lowest light', async () => {