chart/tests/e2e/rth.test.mjs
2026-08-19 05:30:16 +00:00

26 lines
1.1 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { withChart, assertNoPageErrors } from './helpers.mjs';
test('SPY open and close land on weekday Eastern hours, never the weekend',
{ timeout: 180000 }, async () => {
await withChart(async page => {
const marks = await page.evaluate(() => {
const monday = Date.UTC(2026, 7, 17, 0, 0) / 1000;
const sunday = Date.UTC(2026, 7, 16, 12, 0) / 1000;
return {
monday: ConfluenceChart.rthInstants(monday, monday + 24 * 3600),
sunday: ConfluenceChart.rthInstants(sunday, sunday + 6 * 3600),
dst: ConfluenceChart.epochAtEastern(2026, 3, 9, 9, 30),
open: ConfluenceChart.epochAtEastern(2026, 8, 17, 9, 30),
close: ConfluenceChart.epochAtEastern(2026, 8, 17, 16, 0),
};
});
assert.equal(marks.open, 1786973400);
assert.equal(marks.close, 1786996800);
assert.equal(marks.dst, 1773063000);
assert.deepEqual(marks.monday.map(mark => mark.kind), ['open', 'close']);
assert.equal(marks.sunday.length, 0);
assertNoPageErrors(page, assert);
});
});