import { planDmMessageSend } from './dm-message-send.rules'; function makeFile(name: string): File { return new File(['x'], name, { type: 'image/png' }); } describe('planDmMessageSend', () => { it('binds attachments to the same pre-allocated message id', () => { const generateId = () => 'dm-msg-1'; const plan = planDmMessageSend({ generateId, content: 'hello', pendingFiles: [makeFile('a.png'), makeFile('b.png')] }); expect(plan.action.id).toBe('dm-msg-1'); expect(plan.attachmentBinding?.messageId).toBe('dm-msg-1'); expect(plan.attachmentBinding?.files).toHaveLength(2); }); it('returns no attachment binding when there are no pending files', () => { const plan = planDmMessageSend({ generateId: () => 'dm-msg-2', content: 'text only', pendingFiles: [] }); expect(plan.attachmentBinding).toBeNull(); }); });