backend/test/utils/timeConvert.utils.test.ts
Fred Boniface 0a25ae85f5 newStaffLDB-API (#48)
Merge newStaffLDB-API into main.

Ready to deploy

Reviewed-on: #48
2023-10-03 21:35:00 +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);
});
});