/*
 * Copyright (C) 2019 Robert Bosch GmbH Copyright (C) 2019 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MatIconModule } from '@angular/material/icon';
import { click } from '../../../testing/index';

import { BciSidebarNavItemOverlayComponent } from './bci-sidebar-nav-item-overlay.component';

describe('BciSidebarNavItemOverlayComponent', () => {
  let component: BciSidebarNavItemOverlayComponent;
  let fixture: ComponentFixture<BciSidebarNavItemOverlayComponent>;

  beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        imports: [MatIconModule],
        declarations: [BciSidebarNavItemOverlayComponent],
      }).compileComponents();
    })
  );

  beforeEach(() => {
    fixture = TestBed.createComponent(BciSidebarNavItemOverlayComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

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

  it('should emit the closing event when the close window icon is clicked', () => {
    let closeCalled = false;

    component.close.subscribe(() => {
      closeCalled = true;
    });

    const closeButton = fixture.nativeElement.querySelector('.close-button');
    click(closeButton);

    expect(closeCalled).toBeTruthy();
  });
});
