import test from "node:test";
import assert from "node:assert/strict";
import { copyMessage } from "./copy-message.js";

test("copyMessage writes the exact visible message text", async () => {
  let copied;
  const clipboard = { writeText: async (text) => { copied = text; } };

  assert.equal(await copyMessage("line one\nline two", clipboard), true);
  assert.equal(copied, "line one\nline two");
});

test("copyMessage reports failure without exposing clipboard errors", async () => {
  const clipboard = { writeText: async () => { throw new Error("private browser detail"); } };

  assert.equal(await copyMessage("safe text", clipboard), false);
});
