import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { FeedbackComponent } from './feedback.component';
import { FormsModule, NgModel } from '@angular/forms';
import { FeedbackType } from '../../enumerations';

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

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [FormsModule],
      providers: [NgModel],
      declarations: [FeedbackComponent]
    })
      .compileComponents();
  }));

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

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

  it('should emit close on clear message', () => {
    spyOn(component.close, 'emit');
    component.clearMessage();
    expect(component.close.emit).toHaveBeenCalled();
  });

  it('should return messageClass with error-message true', () => {
    component.model = { type: FeedbackType.Error, message: 'Error', displayClose: true };
    expect(component.messageClass).toEqual({
      'gen-msg__error': true,
      'gen-msg__warning': false,
      'gen-msg__notification': false,
      'gen-msg__success': false
    });
  });

  it('should return messageClass with warning true', () => {
    component.model = { type: FeedbackType.Warning, message: 'Warning', displayClose: true };
    expect(component.messageClass).toEqual({
      'gen-msg__error': false,
      'gen-msg__warning': true,
      'gen-msg__notification': false,
      'gen-msg__success': false
    });
  });
});
