Files
sunrise/tests/arrival.test.ts

16 lines
694 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { calculateSun, sunriseAzimuth } from '../src/astronomy/sunCalculator.ts';
import { observer } from '../src/config/observer.ts';
test('arrival faces the selected day’s sunrise, even when entering in the afternoon', () => {
for (const month of ['01', '06', '11']) {
const date = new Date(`2026-${month}-02T15:00:00+09:00`);
const state = calculateSun(date, observer);
const heading = sunriseAzimuth(date, observer);
assert.equal(heading, calculateSun(state.sunrise!, observer).azimuth);
assert.ok(heading > 45 && heading < 135);
assert.ok(Math.abs(heading - state.azimuth) > 60);
}
});