groupedTaskRowTooltip.test.ts 1004 B

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