clipboard.test.ts 798 B

12345678910111213141516171819
  1. import { expect, test } from "bun:test"
  2. import { copyCommand } from "../src/clipboard"
  3. test("prefers Wayland clipboard when available", () => {
  4. expect(copyCommand("linux", true, (name) => name === "wl-copy")).toEqual(["wl-copy"])
  5. })
  6. test("uses osascript on macOS", () => {
  7. expect(copyCommand("darwin", false, (name) => name === "osascript")).toEqual(["osascript"])
  8. })
  9. test("falls back through X11 clipboard commands", () => {
  10. expect(copyCommand("linux", true, (name) => name === "xclip")).toEqual(["xclip", "-selection", "clipboard"])
  11. expect(copyCommand("linux", false, (name) => name === "xsel")).toEqual(["xsel", "--clipboard", "--input"])
  12. })
  13. test("returns undefined when native clipboard is unavailable", () => {
  14. expect(copyCommand("linux", false, () => false)).toBeUndefined()
  15. })