unreadTaskCount.test.ts 896 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. countAllUnreadTasks,
  4. countWorkspaceUnreadTasks,
  5. } from "../src/lib/unreadTaskCount.js";
  6. describe("unread task count", () => {
  7. it("按 workspace 统计未读 task 数", () => {
  8. expect(
  9. countWorkspaceUnreadTasks({
  10. taskUnreadByTaskId: {
  11. "task-1": true,
  12. "task-2": true,
  13. },
  14. }),
  15. ).toBe(2);
  16. });
  17. it("聚合所有 workspace 的未读 task 数", () => {
  18. expect(
  19. countAllUnreadTasks({
  20. "/tmp/workspace-a": {
  21. taskUnreadByTaskId: {
  22. "task-1": true,
  23. "task-2": true,
  24. },
  25. },
  26. "/tmp/workspace-b": {
  27. taskUnreadByTaskId: {
  28. "task-3": true,
  29. },
  30. },
  31. }),
  32. ).toBe(3);
  33. });
  34. it("空 workspace 集合返回 0", () => {
  35. expect(countAllUnreadTasks({})).toBe(0);
  36. });
  37. });