import { describe, expect, it } from 'vitest';
import { formatBlockUntil } from './blocked';

describe('formatBlockUntil', () => {
  const instant = '2026-07-01T12:00:00Z';

  it('formats a valid instant in the given timezone', () => {
    const out = formatBlockUntil(instant, 'en', 'UTC');
    expect(out).not.toBe(instant); // it was localized, not echoed
    expect(out).toContain('2026');
  });

  it('shifts the rendered time by timezone', () => {
    const utc = formatBlockUntil(instant, 'en', 'UTC');
    const ny = formatBlockUntil(instant, 'en', 'America/New_York');
    expect(ny).not.toBe(utc); // 12:00 UTC renders as a different wall-clock in New York
  });

  it('falls back to the raw string for an unparseable instant', () => {
    expect(formatBlockUntil('not-a-date', 'en', 'UTC')).toBe('not-a-date');
  });

  it('does not throw on an invalid timezone, still rendering the date', () => {
    const out = formatBlockUntil(instant, 'en', 'Not/AZone');
    expect(out).toContain('2026');
  });
});
