import { describe, it, expect } from 'vitest';
import { formatConfirmationMessage, parseConfirmationCallback } from './confirmations.js';

describe('formatConfirmationMessage', () => {
  it('formats tool and args into readable message', () => {
    const message = formatConfirmationMessage('shell.exec', { cmd: 'ls -la' });

    expect(message).toContain('shell.exec');
    expect(message).toContain('ls -la');
  });
});

describe('parseConfirmationCallback', () => {
  it('parses approve callback data', () => {
    const result = parseConfirmationCallback('confirm:abc123:approve');

    expect(result).toEqual({
      id: 'abc123',
      approved: true,
    });
  });

  it('parses deny callback data', () => {
    const result = parseConfirmationCallback('confirm:abc123:deny');

    expect(result).toEqual({
      id: 'abc123',
      approved: false,
    });
  });

  it('returns null for invalid callback data', () => {
    expect(parseConfirmationCallback('invalid')).toBeNull();
    expect(parseConfirmationCallback('other:data')).toBeNull();
  });
});
