import { fakeAsync } from '@angular/core/testing';
import { Spectator, createComponentFactory } from '@ngneat/spectator';
import { UiIconModule } from '@ui/icon';
import { ShellHeaderComponent } from './header.component';
import { ShellSectionToggleComponent } from './section-toggle/section-toggle.component';

describe('ShellHeaderComponent', () => {
  let spectator: Spectator<ShellHeaderComponent>;
  const createComponent = createComponentFactory({
    component: ShellHeaderComponent,
    declarations: [ShellSectionToggleComponent],
    imports: [UiIconModule],
  });

  beforeEach(() => (spectator = createComponent()));

  it('should create', () => {
    expect(spectator.component).toBeTruthy();
  });

  describe('toggleMoreMenu', () => {
    it('should toggle more menu', () => {
      spectator.component.toggleMoreMenu();
      expect(spectator.component.moreMenuOpen).toBeTruthy();
      spectator.component.toggleMoreMenu();
      expect(spectator.component.moreMenuOpen).toBeFalsy();
    });

    it('should use the parameter value if provided', () => {
      spectator.component.toggleMoreMenu(true);
      expect(spectator.component.moreMenuOpen).toBeTruthy();
      spectator.component.toggleMoreMenu(false);
      expect(spectator.component.moreMenuOpen).toBeFalsy();
    });
  });
});
