backend/test/utils/timeConvert.utils.test.ts
Fred Boniface 51bae70d6c Run prettier
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-27 20:49:21 +01:00

18 lines
558 B
TypeScript

import { jsUnix, unixLocal } from "../../src/utils/timeConvert.utils";
describe("Time Conversion", () => {
test("Should return unix time (seconds)", () => {
const now = new Date();
const nowJs = now.getTime();
const nowUnix = Math.floor(now.getTime() / 1000);
expect(jsUnix(nowJs)).toEqual(nowUnix);
});
test("Should return locale date string", () => {
const now = new Date();
const nowUnix = Math.floor(now.getTime() / 1000);
const result = now.toLocaleString();
expect(unixLocal(nowUnix)).toEqual(result);
});
});