import { describe, it, expect } from 'vitest';
import { parseDateString } from '../scrapeLakes';

describe('scrapeLakes - parseDateString', () => {
  it('should parse valid date strings correctly', () => {
    // Note: JS Date parsing uses local timezone, so the output ISO string depends on where the test runs.
    // To make it deterministic, we just check if it returns a string and is not null.
    const result = parseDateString('05.06.2026 22:30');
    expect(result).not.toBeNull();
    // Assuming standard parsing, it should contain 2026
    expect(result).toContain('2026-06-05');
  });

  it('should return null for invalid formats', () => {
    expect(parseDateString('')).toBeNull();
    expect(parseDateString('invalid date string')).toBeNull();
    expect(parseDateString('05.06.2026')).toBeNull(); // Missing time
    expect(parseDateString('22:30')).toBeNull(); // Missing date
  });

  it('should return null for malformed parts', () => {
    expect(parseDateString('99.99.9999 99:99')).toBeNull(); // JS Date might parse this as valid overflow, but let's check
    expect(parseDateString('abc def ghi')).toBeNull();
  });
});
