import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { Footer } from './footer';

describe('Footer', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [Footer],
      providers: [provideRouter([])],
    }).compileComponents();
  });

  it('exposes a footer landmark', async () => {
    const fixture = TestBed.createComponent(Footer);
    await fixture.whenStable();
    const root = fixture.nativeElement as HTMLElement;
    expect(root.querySelector('footer[aria-label="Page footer"]')).not.toBeNull();
  });

  it('shows the APF copyright with the current year', async () => {
    const fixture = TestBed.createComponent(Footer);
    await fixture.whenStable();
    const text = (fixture.nativeElement as HTMLElement).textContent ?? '';
    expect(text).toContain('APF France handicap');
    expect(text).toContain(String(new Date().getFullYear()));
  });

  it('renders the accessibility statement link (single, locale-aware via i18n)', async () => {
    const fixture = TestBed.createComponent(Footer);
    await fixture.whenStable();
    const root = fixture.nativeElement as HTMLElement;
    const link = root.querySelector('a[href="/accessibility"]') as HTMLAnchorElement | null;
    expect(link).not.toBeNull();
    expect(link?.textContent?.trim()).toBe('Accessibility statement');
    // The historical `/accessibilite` link is gone — that path now
    // redirects at the route level rather than being a separate link.
    expect(root.querySelector('a[href="/accessibilite"]')).toBeNull();
  });

  it('embeds the locale switcher', async () => {
    const fixture = TestBed.createComponent(Footer);
    await fixture.whenStable();
    expect(fixture.nativeElement.querySelector('app-locale-switcher')).not.toBeNull();
  });
});
