embedded-search-shell.test.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { describe, expect, it } from "vitest";
  2. import type { ExecutionShellSelection } from "@zcode/contracts";
  3. import {
  4. shouldInjectEmbeddedSearchBashPrelude,
  5. supportsEmbeddedSearchShellSelection,
  6. } from "../src/embedded-search/shell.js";
  7. describe("shouldInjectEmbeddedSearchBashPrelude", () => {
  8. it("enables runtime find/grep alias injection by default", () => {
  9. expect(shouldInjectEmbeddedSearchBashPrelude()).toBe(true);
  10. });
  11. });
  12. describe("supportsEmbeddedSearchShellSelection", () => {
  13. it("supports POSIX and Git Bash session shells for runtime prelude injection", () => {
  14. expect(supportsEmbeddedSearchShellSelection(undefined)).toBe(false);
  15. expect(
  16. supportsEmbeddedSearchShellSelection({
  17. dialect: "posix",
  18. display: { name: "bash" },
  19. path: "/bin/bash",
  20. source: "auto-detected",
  21. } satisfies ExecutionShellSelection),
  22. ).toBe(true);
  23. expect(
  24. supportsEmbeddedSearchShellSelection({
  25. dialect: "git-bash",
  26. display: { name: "Git Bash" },
  27. path: "C:\\Program Files\\Git\\bin\\bash.exe",
  28. source: "auto-detected",
  29. } satisfies ExecutionShellSelection),
  30. ).toBe(true);
  31. expect(
  32. supportsEmbeddedSearchShellSelection({
  33. dialect: "cmd",
  34. display: { name: "CMD" },
  35. path: "cmd.exe",
  36. source: "user-config",
  37. } satisfies ExecutionShellSelection),
  38. ).toBe(false);
  39. expect(
  40. supportsEmbeddedSearchShellSelection({
  41. dialect: "legacy-shell",
  42. display: { name: "system shell" },
  43. source: "legacy-fallback",
  44. } satisfies ExecutionShellSelection),
  45. ).toBe(false);
  46. });
  47. });