groupedTaskRowTooltip.test.ts 952 B

12345678910111213141516171819202122232425262728293031
  1. import { describe, expect, it } from "vitest";
  2. import type { ZCodeTaskChangeSummary } from "@zcode/shared";
  3. import { formatGroupedTaskHoverChangeParts } from "@/project-sidebar/grouped/task-row-tooltip.js";
  4. function createChangeSummary(added: number, removed: number): ZCodeTaskChangeSummary {
  5. return {
  6. fileCount: 1,
  7. added,
  8. removed,
  9. files: [
  10. {
  11. path: "/workspace/file.ts",
  12. added,
  13. removed,
  14. writeCount: 1,
  15. lastTurnIndex: 1,
  16. },
  17. ],
  18. };
  19. }
  20. describe("grouped task row tooltip", () => {
  21. it("formats non-zero change stats for the hover tooltip", () => {
  22. expect(formatGroupedTaskHoverChangeParts(createChangeSummary(5, 2))).toEqual(["+5", "-2"]);
  23. });
  24. it("omits zero change stats", () => {
  25. expect(formatGroupedTaskHoverChangeParts(createChangeSummary(0, 3))).toEqual(["-3"]);
  26. expect(formatGroupedTaskHoverChangeParts(createChangeSummary(0, 0))).toEqual([]);
  27. });
  28. });