import {
  describe,
  expect,
  it
} from 'vitest';

import {
  buildIncomingCallNotification,
  buildInCallNotification,
  resolveCallNotificationAction
} from './call-notification.rules';

describe('call-notification.rules', () => {
  it('builds an incoming call notification payload', () => {
    expect(buildIncomingCallNotification('Alex', 'call-1')).toMatchObject({
      title: 'Incoming call',
      body: 'Alex is calling you',
      callId: 'call-1',
      kind: 'incoming',
      actions: [{ id: 'answer', title: 'Answer' }, { id: 'hangup', title: 'Decline' }]
    });
  });

  it('builds a persistent in-call notification with action ids', () => {
    const payload = buildInCallNotification({
      callId: 'call-2',
      displayName: 'Team call',
      isMuted: false
    });

    expect(payload).toMatchObject({
      title: 'Team call',
      body: 'Call in progress',
      callId: 'call-2',
      kind: 'active',
      actions: [{ id: 'mute', title: 'Mute' }, { id: 'hangup', title: 'Hang up' }]
    });
  });

  it('maps mute action to toggle mute intent', () => {
    expect(resolveCallNotificationAction('mute')).toBe('toggle-mute');
    expect(resolveCallNotificationAction('hangup')).toBe('hang-up');
    expect(resolveCallNotificationAction('answer')).toBe('answer');
    expect(resolveCallNotificationAction('unknown')).toBeNull();
  });
});
