utils.test.ts 810 B

12345678910111213141516171819202122232425
  1. import { test, expect } from "vitest";
  2. import {
  3. formatTimestamp,
  4. getExtension,
  5. removeApiKey,
  6. } from "../../src/utils/utils";
  7. test("removeApiKey", () => {
  8. const data = [{ args: { LLM_API_KEY: "key", LANGUAGE: "en" } }];
  9. expect(removeApiKey(data)).toEqual([{ args: { LANGUAGE: "en" } }]);
  10. });
  11. test("getExtension", () => {
  12. expect(getExtension("main.go")).toBe("go");
  13. expect(getExtension("get-extension.test.ts")).toBe("ts");
  14. expect(getExtension("directory")).toBe("");
  15. });
  16. test("formatTimestamp", () => {
  17. const morningDate = new Date("2021-10-10T10:10:10.000").toISOString();
  18. expect(formatTimestamp(morningDate)).toBe("10/10/2021, 10:10:10");
  19. const eveningDate = new Date("2021-10-10T22:10:10.000").toISOString();
  20. expect(formatTimestamp(eveningDate)).toBe("10/10/2021, 22:10:10");
  21. });