CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/database/pool/util.test.ts
Views: 687
1
import { timeInSeconds } from "./util";
2
3
test("use the timeInSeconds code gen function", () => {
4
const s = timeInSeconds("public_paths.last_edited", "last_edited");
5
expect(s).toEqual(
6
" (EXTRACT(EPOCH FROM public_paths.last_edited)*1000)::FLOAT as last_edited "
7
);
8
});
9
10
import { expireTime } from "./util";
11
12
test("using expireTime to compute a time in the future", () => {
13
const now = new Date().getTime();
14
const now10 = expireTime(10).getTime();
15
// sometimes, this is off by one. expect.toBeCloseTo only checks after the decimal point
16
// increasing to 100 due to flakiness -- https://github.com/sagemathinc/cocalc/issues/6387
17
expect(Math.abs(now10 - now - 10000)).toBeLessThanOrEqual(100);
18
});
19
20