import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { <%= classify(name) %> } from './<%= dasherize(name) %>';

@Component({
  imports: [<%= classify(name) %>],
  template: `<<%= selector %> interactive />`,
})
class Host {}

describe('<%= classify(name) %>', () => {
  let fixture: ComponentFixture<Host>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({ imports: [Host] }).compileComponents();
    fixture = TestBed.createComponent(Host);
    fixture.detectChanges();
  });

  it('marks the current step with aria-current="step"', () => {
    const current = fixture.nativeElement.querySelector('[aria-current="step"]');

    expect(current?.textContent).toContain('Descobrir');
  });

  it('moves current step with arrow keys when interactive', () => {
    const buttons = fixture.debugElement.queryAll(By.css('button'));

    buttons[0].triggerEventHandler('keydown', new KeyboardEvent('keydown', { key: 'ArrowRight' }));
    fixture.detectChanges();

    expect(fixture.nativeElement.querySelector('[aria-current="step"]').textContent).toContain('Construir');
  });
});
