backend/test/utils/timeConvert.utils.test.ts
Fred Boniface 203d5e56b7 Add additional tests
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-20 14:07:29 +01:00

17 lines
555 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);
})
});