import { test } from 'node:test' import assert from 'node:assert/strict' import { spawnSync } from 'node:child_process' import { fileURLToPath } from 'node:url' const cli = fileURLToPath(new URL('../bin/entangle.mjs', import.meta.url)) const run = (...args) => spawnSync(process.execPath, [cli, ...args], { encoding: 'utf8' }) test('the value of a space-spelled option is not taken as the owner', () => { // report looks for data/.json; the owner named in the error proves which // argument was taken as the owner. const r = run('report', '--domain', 'not-the-owner', 'no-such-owner') assert.match(r.stderr, /no-such-owner\.json not found/) }) test('a boolean flag does not swallow the next argument', () => { const r = run('report', '--offline', 'no-such-owner') assert.match(r.stderr, /no-such-owner\.json not found/) }) test('an option missing its value is an error', () => { const r = run('plan', 'no-such-owner', '--domain') assert.notEqual(r.status, 0) assert.match(r.stderr, /--domain needs a value/) })