import formatDateToLocalTime from '../utils/dateFormat'; // adjust the path

describe('formatDateToLocalTime', () => {
  test('should return an empty string when no input is provided', () => {
    expect(formatDateToLocalTime()).toBe('');
  });

  test('should format the ISO date string to local time', () => {
    // Using a fixed date string for predictable test results
    const isoString = '2024-09-10T10:30:00Z'; // 10th Sept 2024, 10:30:00 UTC
    const result = formatDateToLocalTime(isoString);
    
    // Extract current timezone offset for accurate expectations
    const expectedDate = new Date(isoString).toLocaleString('en-US', {
      weekday: 'short',
      year: 'numeric',
      month: 'numeric',
      day: '2-digit',
      hour: 'numeric',
      minute: '2-digit',
      second: '2-digit',
      hour12: true,
      timeZoneName: 'short'
    });

    expect(result).toBe(expectedDate);
  });

  test('should handle invalid date input gracefully', () => {
    const result = formatDateToLocalTime('invalid-date');
    expect(result).toBe('Invalid Date');
  });
});
