import { TestBed, ComponentFixture } from '@angular/core/testing';
import { HistoryStateFacade } from '@shelf-store/history';
import { ShelfHistoryHeaderComponent } from './history-header.component';
import { ShelfOrderDetailsCardModule } from '../../../components/order-details-card';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { DetailsFacade } from '@shelf-store/details';
import { DateAdapter } from '@isa-ui/core/date';

fdescribe('ShelfHistoryHeaderComponent', () => {
  let fixture: ComponentFixture<ShelfHistoryHeaderComponent>;
  let component: ShelfHistoryHeaderComponent;
  let facade: HistoryStateFacade;

  const id = 123;

  beforeEach(async () => {
    TestBed.configureTestingModule({
      providers: [
        DateAdapter,
        {
          provide: HistoryStateFacade,
          useValue: jasmine.createSpyObj('historyStateFacade', {
            reloadHistory: () => {},
          }),
        },
        {
          provide: DetailsFacade,
          useValue: jasmine.createSpy('detailsFacade'),
        },
      ],
      imports: [ShelfOrderDetailsCardModule],
      declarations: [ShelfHistoryHeaderComponent],
      schemas: [NO_ERRORS_SCHEMA],
    }).compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(ShelfHistoryHeaderComponent);
    component = fixture.componentInstance;
    facade = TestBed.inject(HistoryStateFacade);

    component.orderItemSubsetId = id;
    fixture.detectChanges();
  });

  xit('should be created', () => {
    expect(component instanceof ShelfHistoryHeaderComponent).toBeTruthy();
  });

  describe('updateHistory', () => {
    beforeEach(() => {
      spyOn(component, 'updateHistory').and.callThrough();
    });

    xit('should call reloadHistory on the state facade', () => {
      component.updateHistory();

      expect(facade.reloadHistory).toHaveBeenCalledWith(id);
    });
  });
});
