import { notificationDeepLink } from './deepLink';
import type { AppNotification, NotificationData } from './types';

function make(data: NotificationData): AppNotification {
  return { id: 1, type: 'x', title: 't', body: null, isRead: false, createdAt: '2026-07-01T00:00:00Z', data };
}

describe('notificationDeepLink', () => {
  it('routes a booking to the customer booking detail vs the nurse visit detail', () => {
    expect(notificationDeepLink(make({ kind: 'booking', bookingId: 5001 }), 'customer')).toBe('/bookings/5001');
    expect(notificationDeepLink(make({ kind: 'booking', bookingId: 5001 }), 'nurse')).toBe('/nurse/visits/5001');
  });

  it('routes a ticket to the right shell', () => {
    expect(notificationDeepLink(make({ kind: 'ticket', ticketId: 12 }), 'customer')).toBe('/support/tickets/12');
    expect(notificationDeepLink(make({ kind: 'ticket', ticketId: 12 }), 'nurse')).toBe('/nurse/support/tickets/12');
  });

  it('routes a refund to the customer refund status', () => {
    expect(notificationDeepLink(make({ kind: 'refund', bookingId: 5004 }), 'customer')).toBe('/bookings/5004/refund_status');
  });

  it('routes a payout to the nurse payout detail', () => {
    expect(notificationDeepLink(make({ kind: 'payout', payoutId: 7001 }), 'nurse')).toBe('/nurse/earnings/payouts/7001');
  });

  it('routes a review to the public nurse profile for a customer, nowhere for a nurse', () => {
    expect(notificationDeepLink(make({ kind: 'nurse_profile', nurseProfileId: 1 }), 'customer')).toBe('/search/nurse/1');
    expect(notificationDeepLink(make({ kind: 'nurse_profile', nurseProfileId: 1 }), 'nurse')).toBeNull();
  });

  it('returns null (non-navigable, never broken) when there is nothing to open', () => {
    expect(notificationDeepLink(make({ kind: 'none' }), 'customer')).toBeNull();
  });
});
