workspaceVisibleCommand.test.ts 884 B

123456789101112131415161718192021222324252627282930
  1. import { describe, expect, it, vi } from "vitest";
  2. import { runWorkspaceVisibleCommand } from "@/lib/workspaceVisibleCommand.js";
  3. describe("runWorkspaceVisibleCommand", () => {
  4. it("returns to workspace before running a workspace command hidden behind settings", () => {
  5. const calls: string[] = [];
  6. runWorkspaceVisibleCommand({
  7. isWorkspaceVisible: false,
  8. onReturnToWorkspace: () => calls.push("return"),
  9. run: () => calls.push("command"),
  10. });
  11. expect(calls).toEqual(["return", "command"]);
  12. });
  13. it("runs directly when workspace is already visible", () => {
  14. const onReturnToWorkspace = vi.fn();
  15. const run = vi.fn();
  16. runWorkspaceVisibleCommand({
  17. isWorkspaceVisible: true,
  18. onReturnToWorkspace,
  19. run,
  20. });
  21. expect(onReturnToWorkspace).not.toHaveBeenCalled();
  22. expect(run).toHaveBeenCalledTimes(1);
  23. });
  24. });