2023-09-20 14:07:29 +01:00
|
|
|
import { jsUnix, unixLocal } from "../../src/utils/timeConvert.utils";
|
|
|
|
|
|
|
|
describe("Time Conversion", () => {
|
2023-09-27 20:49:21 +01:00
|
|
|
test("Should return unix time (seconds)", () => {
|
2023-09-20 14:07:29 +01:00
|
|
|
const now = new Date();
|
|
|
|
const nowJs = now.getTime();
|
|
|
|
const nowUnix = Math.floor(now.getTime() / 1000);
|
|
|
|
expect(jsUnix(nowJs)).toEqual(nowUnix);
|
2023-09-27 20:49:21 +01:00
|
|
|
});
|
2023-09-20 14:07:29 +01:00
|
|
|
|
2023-09-27 20:49:21 +01:00
|
|
|
test("Should return locale date string", () => {
|
2023-09-20 14:07:29 +01:00
|
|
|
const now = new Date();
|
|
|
|
const nowUnix = Math.floor(now.getTime() / 1000);
|
|
|
|
const result = now.toLocaleString();
|
|
|
|
expect(unixLocal(nowUnix)).toEqual(result);
|
2023-09-27 20:49:21 +01:00
|
|
|
});
|
|
|
|
});
|