import { expect,test } from 'bun:test'; import { renderOutbound,renderReply } from './format.js';
const i={sessionId:'s',name:'ci-cd-incremental-2',nameSource:'session-name' as const,terminal:'gnome-terminal',workspace:'Workspace 5',cwd:'/',host:'h'};
test('renders owner contract',()=>{expect(renderOutbound(i,'🦊','m7k3q','REQ-142','hello')).toBe('🦊 "ci-cd-incremental-2" (gnome-terminal, Workspace 5) sent you a message #REQ-142 #m7k3q:\nresume: cd / && claude --resume s\nhello');expect(renderReply(i,'🦊','m7k3q','m8b1p','ok')).toBe('🦊 "ci-cd-incremental-2" re #m7k3q → #m8b1p:\nresume: cd / && claude --resume s\nok')});
test('renders only message text when it did not come from a session',()=>{const nonSession={...i,sessionId:'unknown-42',name:'unresolved session',nameSource:'unresolved' as const};expect(renderOutbound(nonSession,'🦊','m7k3q',null,'hello')).toBe('hello');expect(renderReply(nonSession,'🦊','m7k3q','m8b1p','ok')).toBe('ok')});
// Regression: when a message is tied to a session, the name the owner sees must carry what
// it takes to resume it. Messages without a real session id intentionally carry no header.
test('a rendered session message carries a resume command',()=>{
  const known=renderOutbound(i,'🦊','m7k3q',null,'hi');
  expect(known).toContain('resume: cd / && claude --resume s');
});
