import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { RemissionListCardHeaderComponent } from './card-header.component';
import { remissionProducts } from '../../../mocks';

describe('CardHeaderComponent', () => {
  let fixture: ComponentFixture<RemissionListCardHeaderComponent>;
  let component: RemissionListCardHeaderComponent;
  let element: HTMLElement;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [RemissionListCardHeaderComponent],
    }).compileComponents();

    fixture = TestBed.createComponent(RemissionListCardHeaderComponent);
    component = fixture.componentInstance;
    element = fixture.nativeElement;

    component.product = remissionProducts[0];

    fixture.detectChanges();
  }));

  it('should show the authors', () => {
    const authors = element.querySelector('.authors');

    expect(authors).toBeTruthy();
    expect(authors.textContent).toContain(remissionProducts[0].contributors);
  });

  it('should show the title', () => {
    const title = element.querySelector('.title');

    expect(title).toBeTruthy();
    expect(title.textContent).toContain(remissionProducts[0].name);
  });

  it('should show the productgroup', () => {
    const productGroup = element.querySelector('.group > .number');
    const productGroupName = element.querySelector('.group > .name');

    expect(productGroup).toBeTruthy();
    expect(productGroupName).toBeTruthy();

    expect(productGroup.textContent).toContain(remissionProducts[0].productGroup);
    expect(productGroupName.textContent).toContain(remissionProducts[0].productGroupName);
  });
});
