// Row 288: the Console's save option carries only the caller's args over its own transport. import test from 'node:test'; import assert from 'node:assert/strict'; import { consoleBus, userOptionsFor } from '../src/console-bus.mjs'; test('C2-02: library save option is absent without --send and forwards no editor or identity', async () => { const calls = [], call = async (verb, args) => { calls.push({ verb, args }); return { commit: 'a'.repeat(40) }; }; assert.equal(consoleBus(call).librarySave, null); const args = { project: 'books', path: 'Book One/Chapters/01.md', base: 'b'.repeat(40), content: 'her text\n' }; assert.equal((await consoleBus(call, { send: true }).librarySave(args)).commit, 'a'.repeat(40)); assert.deepEqual(calls, [{ verb: 'library.file.save', args }]); assert.deepEqual(Object.keys(calls[0].args).sort(), ['base', 'content', 'path', 'project']); }); test('C2-02: user save option uses that user transport; owner transport is never called', async () => { const calls = []; const options = userOptionsFor({ owner: () => { throw Error('owner transport touched'); }, send: true, transport: user => async (verb, args) => { calls.push({ user, verb, args }); } }); const args = { project: 'books', path: 'Book One/Chapters/01.md', base: null, content: 'fixture' }; await options({ user: 'reader' }).librarySave(args); assert.deepEqual(calls, [{ user: 'reader', verb: 'library.file.save', args }]); });