import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";

test("project api lists folders and registers existing or new projects", async () => {
  const source = await readFile(new URL("./project-api.js", import.meta.url), "utf8");
  assert.match(source, /request\("\/project-folders"\)/);
  assert.match(source, /request\("\/workspaces"/);
  assert.match(source, /method: "POST"/);
  assert.match(source, /body: \{ name, create \}/);
  assert.match(source, /request\(`\/folder-browser\?folderId=/);
  assert.match(source, /request\("\/folder-browser\/folders"/);
  assert.match(source, /body: \{ parentId, name \}/);
  assert.match(source, /body: \{ folderId \}/);
});
