openpondai/agents/news-bot
OpenTool app
typescript
import { describe, expect, test } from "bun:test";
import { downsampleBacktestCheckpoints } from "./news-backtest";
describe("downsampleBacktestCheckpoints", () => {
test("keeps the original list when it is already within the cap", () => {
const checkpoints = [
"2026-03-18T00:00:00.000Z",
"2026-03-19T00:00:00.000Z",
"2026-03-20T00:00:00.000Z",
];
expect(downsampleBacktestCheckpoints(checkpoints, 3)).toEqual(checkpoints);
});
test("preserves the start and end checkpoints while reducing intermediate points", () => {
const checkpoints = [
"2026-03-18T00:00:00.000Z",
"2026-03-19T00:00:00.000Z",
"2026-03-20T00:00:00.000Z",
"2026-03-21T00:00:00.000Z",
"2026-03-22T00:00:00.000Z",
"2026-03-23T00:00:00.000Z",
"2026-03-24T00:00:00.000Z",
];
expect(downsampleBacktestCheckpoints(checkpoints, 3)).toEqual([
"2026-03-18T00:00:00.000Z",
"2026-03-21T00:00:00.000Z",
"2026-03-24T00:00:00.000Z",
]);
});
});