import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import { resolve } from "node:path"; import { test } from "node:test"; const cli = resolve(process.cwd(), "dist/src/capability-language/cli.js"); const runResourceCheck = (source: string) => spawnSync( process.execPath, [cli, "--resource", "--check", "-"], { input: source, encoding: "utf8" }, ); test("capability CLI checks a standalone interface resource", () => { const result = runResourceCheck(`interface WeatherBase id "interface:weather-base" revision "interface:weather-base@1" { value temperature id "member:weather:temperature" : double { get id "operation:weather:temperature:get"; } }\n`); assert.equal(result.status, 0, result.stderr); assert.equal(result.stdout, ""); }); test("capability CLI reports invalid standalone interface members", () => { const result = runResourceCheck(`interface WeatherBase id "interface:weather-base" revision "interface:weather-base@1" { value temperature : definitely-not-a-type; }\n`); assert.notEqual(result.status, 0); assert.match(result.stderr, /syntax-error/); });