Files
mtusi2026lab7/student-tests/openobserve-search-window.test.ts

26 lines
812 B
TypeScript

import { expect, test } from "bun:test";
import { nativeSearchWindow } from "../scripts/openobserve-search-window";
test("actual fractional filesystem mtime serializes native integer microseconds", () => {
const mtime = 1794785761292.7983;
const value = nativeSearchWindow(mtime - 900000, mtime);
expect(value).toEqual({
start_time: 1794784861292798,
end_time: 1794785761292798,
});
expect(JSON.parse(JSON.stringify(value))).toEqual(value);
});
for (const [start, end] of [
[NaN, 1],
[1, Infinity],
[-1, 100],
[1, Number.MAX_VALUE],
[10, 1],
[1, 1],
[1, 3600002],
])
test(`invalid search window ${String(start)} ${String(end)} fails before a native call`, () => {
expect(() => nativeSearchWindow(start, end)).toThrow(
"INVALID_OPENOBSERVE_SEARCH_WINDOW",
);
});