123456789101112131415161718192021 |
- import { describe, expect, it } from "vitest";
- import moment from "moment";
- function timeFormat(time: any) {
- return moment(time).format("YYYY-MM-DD HH:mm:ss");
- }
- describe("momentTest", () => {
- it("test moment format", () => {
- const date = {
- timestampt: 1649302583396,
- timeString: "2022-04-07 11:36:23",
- dateObj: new Date(1649302583396),
- };
- const eqTimeStr = "2022-04-07 11:36:23";
- expect(timeFormat(date.timestampt)).toEqual(eqTimeStr);
- expect(timeFormat(date.timeString)).toEqual(eqTimeStr);
- expect(timeFormat(date.dateObj)).toEqual(eqTimeStr);
- });
- });
|