import { DEFAULT_ORG_TIMEZONE } from '../common/timezone/timezone.constants';
import {
  getUtcStartEndOfDate,
} from './helpers';

describe('getUtcStartEndOfDate', () => {
  it('uses Asia/Dhaka calendar day for yyyy-MM-dd input', () => {
    const { startUtc, endUtc } = getUtcStartEndOfDate(
      '2026-06-15',
      DEFAULT_ORG_TIMEZONE,
    );

    expect(startUtc.toISOString()).toBe('2026-06-14T18:00:00.000Z');
    expect(endUtc.toISOString()).toBe('2026-06-15T17:59:59.999Z');
  });

  it('maps the same instant to different calendar days by timezone', () => {
    const instant = new Date('2026-01-15T20:30:00.000Z');

    const dhaka = getUtcStartEndOfDate(instant, 'Asia/Dhaka');
    const newYork = getUtcStartEndOfDate(instant, 'America/New_York');

    expect(dhaka.startUtc.toISOString()).toBe('2026-01-15T18:00:00.000Z');
    expect(newYork.startUtc.toISOString()).toBe('2026-01-15T05:00:00.000Z');
  });

  it('handles UTC timezone boundaries', () => {
    const instant = new Date('2026-03-10T23:30:00.000Z');
    const { startUtc, endUtc } = getUtcStartEndOfDate(instant, 'UTC');

    expect(startUtc.toISOString()).toBe('2026-03-10T00:00:00.000Z');
    expect(endUtc.toISOString()).toBe('2026-03-10T23:59:59.999Z');
  });
});
