18 lines
558 B
TypeScript
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);
|
|
});
|
|
});
|