Files
ai-coding-skills/skills/atlassian/shared/scripts/tests/command-helpers.test.ts
T
2026-05-03 21:45:49 -05:00

44 lines
1.7 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { dryRunResponse, resolveFormat } from "../src/command-helpers.js";
// ── dryRunResponse ────────────────────────────────────────────────────────
test("dryRunResponse wraps data with ok:true and dryRun:true", () => {
const data = { method: "POST", url: "https://example.com/api/v2/pages" };
const result = dryRunResponse(data);
assert.equal(result.ok, true);
assert.equal(result.dryRun, true);
assert.deepEqual(result.data, data);
});
test("dryRunResponse preserves the exact data reference", () => {
const data = { nested: { key: "value" } };
const result = dryRunResponse(data);
assert.strictEqual(result.data, data);
});
test("dryRunResponse works with primitive data", () => {
const result = dryRunResponse("dry-run-string");
assert.equal(result.ok, true);
assert.equal(result.dryRun, true);
assert.equal(result.data, "dry-run-string");
});
// ── resolveFormat ─────────────────────────────────────────────────────────
test("resolveFormat returns json by default for undefined", () => {
assert.equal(resolveFormat(undefined), "json");
});
test("resolveFormat returns json for unrecognised values", () => {
assert.equal(resolveFormat("xml"), "json");
assert.equal(resolveFormat(""), "json");
assert.equal(resolveFormat("TEXT"), "json");
});
test("resolveFormat returns text only for the exact string 'text'", () => {
assert.equal(resolveFormat("text"), "text");
});