import { DateTimeFormat } from '../models/date-time-format';
import { DateTimeFormatterService } from '../services/date-time-formatter.service';
import { AppDateTimePipe } from './app-date-time.pipe';

describe('AppDateTimePipe', () => {
  let formatter: DateTimeFormatterService;
  let pipe: AppDateTimePipe;

  beforeEach(() => {
    formatter = new DateTimeFormatterService();
    pipe = new AppDateTimePipe(formatter);
  });

  it('matches the formatter service output', () => {
    const value = '2026-07-20T14:30:45.000Z';
    const expected = formatter.format(value, {
      format: DateTimeFormat.LongDateTime,
      timeZone: 'Asia/Dubai',
      locale: 'en-GB',
      fallback: 'N/A'
    });

    expect(pipe.transform(
      value,
      DateTimeFormat.LongDateTime,
      'Asia/Dubai',
      'en-GB',
      'N/A'
    )).toBe(expected);
  });

  it('passes a custom fallback through to the formatter', () => {
    expect(pipe.transform(null, DateTimeFormat.Date, 'UTC', 'en-GB', 'N/A')).toBe('N/A');
  });
});
