mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-09-29 12:47:14 -05:00
19 lines
704 B
JavaScript
19 lines
704 B
JavaScript
import { describe, expect, it } from 'vitest';
|
|
import { nextRunAt, HOUR_MS, GRACE_MS } from './src/schedule.mjs';
|
|
|
|
const HOUR = Date.UTC(2026, 8, 4, 14, 0, 0); // 14:00:00 UTC
|
|
const t = seconds => HOUR + seconds * 1000;
|
|
|
|
describe('nextRunAt', () => {
|
|
it('targets :00:10 of the current hour when that is still ahead', () => {
|
|
expect(nextRunAt(t(0))).toBe(HOUR + GRACE_MS);
|
|
expect(nextRunAt(t(9))).toBe(HOUR + GRACE_MS);
|
|
});
|
|
|
|
it('moves to the next hour once :00:10 has passed', () => {
|
|
expect(nextRunAt(t(10))).toBe(HOUR + HOUR_MS + GRACE_MS);
|
|
expect(nextRunAt(t(12))).toBe(HOUR + HOUR_MS + GRACE_MS);
|
|
expect(nextRunAt(t(59 * 60 + 55))).toBe(HOUR + HOUR_MS + GRACE_MS);
|
|
});
|
|
});
|