hardlounge/test/client/js/helpers/localetimeTest.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

18 lines
539 B
TypeScript

import {expect} from "chai";
import localetime from "../../../../client/js/helpers/localetime";
describe("localetime helper", () => {
it("should render a human-readable date", () => {
// 12PM in UTC time
const date = new Date("2014-05-22T12:00:00Z");
// Offset between UTC and local timezone
const offset = date.getTimezoneOffset() * 60 * 1000;
// Pretend local timezone is UTC by moving the clock of that offset
const time = date.getTime() + offset;
expect(localetime(time)).to.equal("22 May 2014, 12:00:00");
});
});