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

import { Component, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ColumnItemDirective } from './column-item.directive';

@Component({
  template:
    '<div style="position: relative"><div bciColumnItem style="height: 100%; position: relative; top: 24px;">dummy</div></div>',
  selector: 'bci-list-item-dummy',
})
class ListItemDummyComponent {
  @ViewChild(ColumnItemDirective) directive: ColumnItemDirective;
}

describe('ColumnItemDirective', () => {
  let host: ListItemDummyComponent;
  let fixture: ComponentFixture<ListItemDummyComponent>;

  beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        declarations: [ColumnItemDirective, ListItemDummyComponent],
      }).compileComponents();
    })
  );

  beforeEach(() => {
    fixture = TestBed.createComponent(ListItemDummyComponent);
    host = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('label input', () => {
    const label = 'dummyLabel';
    host.directive.label = label;
    expect(host.directive.getLabel()).toBe(label);
  });

  it('active', () => {
    host.directive.setActiveStyles();
    expect(host.directive.isActive).toBe(true);

    host.directive.setInactiveStyles();
    expect(host.directive.isActive).toBe(false);
  });

  // FIXME: offsetTop not possible in jest
  xit('offsetTop', () => {
    const offset = host.directive.offsetTop;
    expect(offset).toBe(24);
  });
});
