import { describe, expect, it } from 'vitest';

import {
  isValidEsaResourceUrl,
  toggleEsaFaq,
} from '@/business/esa-funding/selectors';

describe('ESA funding selectors', () => {
  it('toggles FAQ expansion', () => {
    expect(toggleEsaFaq(0, 0)).toBeNull();
    expect(toggleEsaFaq(0, 1)).toBe(1);
    expect(toggleEsaFaq(null, 1)).toBe(1);
  });

  it('validates resource URLs', () => {
    expect(isValidEsaResourceUrl('https://example.com')).toBe(true);
    expect(isValidEsaResourceUrl('http://example.com')).toBe(true);
    expect(isValidEsaResourceUrl('#')).toBe(false);
    expect(isValidEsaResourceUrl('mailto:test@example.com')).toBe(false);
    expect(isValidEsaResourceUrl('not a url')).toBe(false);
  });
});
