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

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MatBadgeModule } from '@angular/material/badge';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { By } from '@angular/platform-browser';
import { CommandbarButtonComponent } from './commandbar-button.component';

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

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

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

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

  it('should display aria-label', () => {        
    component.ariaLabel = 'Test Label';
    fixture.detectChanges();
    const button =fixture.debugElement.query(By.css('.commandbar-item')).nativeElement;
    expect(button.getAttribute('aria-label')).toEqual('Test Label');
  });

  it('should not display aria-label', () => {    
    component.ariaLabel = '';
    fixture.detectChanges();
    const button =fixture.debugElement.query(By.css('.commandbar-item')).nativeElement;
    expect(button.ariaLabel).toBeFalsy();
  });

});
