Simplify Threads captions and capture five minutes after sunrise
This commit is contained in:
@@ -3,6 +3,12 @@ import assert from 'node:assert/strict';
|
||||
import { loadCaptions, weatherKey, renderCaption } from '../server/threads/captions.ts';
|
||||
|
||||
const sample = { cloudCover: 10, visibility: 10000, rain: 0, snowfall: 0 };
|
||||
test('default post shows sunrise time rather than the five-minute-later capture time', () => {
|
||||
const config = loadCaptions(new URL('../.threads-captions.sample.json', import.meta.url));
|
||||
const result = renderCaption(config, { weather: { ...sample, cloudCover: 90 }, capturedAt: '2026-11-01T21:58:00Z',
|
||||
sunrise: '2026-11-01T21:53:00Z', url: 'https://sunrise.horoli.kr', test: false });
|
||||
assert.equal(result.text, '오늘의 관악산 일출이에요\n2026.11.02 · 일출 06:53\n날씨: 흐림\nsunrise.horoli.kr');
|
||||
});
|
||||
test('caption weather uses precipitation first and does not assume missing data means clear', () => {
|
||||
const config = loadCaptions();
|
||||
assert.equal(weatherKey({ ...sample, rain: 1, snowfall: 1 }, config), 'snow');
|
||||
|
||||
@@ -10,6 +10,7 @@ test('schedule uses the Korean date and existing SunCalc sunrise', () => {
|
||||
assert.equal(schedule.date, '2026-11-02');
|
||||
assert.equal(schedule.sunrise.getTime(), calculateSun(now, observer).sunrise!.getTime());
|
||||
assert.equal(+schedule.sunrise - +schedule.prepareAt, 300_000);
|
||||
assert.equal(+schedule.captureAt - +schedule.sunrise, 300_000);
|
||||
});
|
||||
|
||||
test('publishing waits for ready media and persists intent before sending', async () => {
|
||||
|
||||
Reference in New Issue
Block a user