import { signOmnlWebhookBody, verifyOmnlWebhookSignature } from './omnl-webhooks';

describe('omnl-webhooks', () => {
  it('signOmnlWebhookBody produces sha256= prefix', () => {
    const raw = '{"event":"ReserveCommitted","ts":"2026-01-01T00:00:00.000Z"}';
    const sig = signOmnlWebhookBody(raw, 'secret');
    expect(sig.startsWith('sha256=')).toBe(true);
    expect(sig.length).toBeGreaterThan(10);
  });

  it('verifyOmnlWebhookSignature accepts matching signature', () => {
    const raw = '{"a":1}';
    const secret = 'k';
    const sig = signOmnlWebhookBody(raw, secret);
    expect(verifyOmnlWebhookSignature(raw, sig, secret)).toBe(true);
    expect(verifyOmnlWebhookSignature(raw, 'sha256=deadbeef', secret)).toBe(false);
  });
});
