// import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
// import { fakeAsync } from '@angular/core/testing';
// import { DomainAvailabilityService } from '@domain/availability';
// import { createComponentFactory, Spectator } from '@ngneat/spectator';
// import { PackageItemDTO } from '@generated/swagger/wws-api';
// import { MockComponent } from 'ng-mocks';
// import { of } from 'rxjs';
// import { PackageDetailsListItemComponent } from './package-details-list-item.component';
// import { PackageDetailsListComponent } from './package-details-list.component';
// import { PackageDetailsListStore } from './package-details-list.store';

// describe('PackageDetailsListComponent', () => {
//   let spectator: Spectator<PackageDetailsListComponent>;
//   let packageDetailsListStore: jasmine.SpyObj<PackageDetailsListStore>;

//   const createComponent = createComponentFactory({
//     component: PackageDetailsListComponent,
//     imports: [ScrollingModule],
//     declarations: [MockComponent(PackageDetailsListItemComponent)],
//     mocks: [DomainAvailabilityService],
//   });

//   beforeEach(() => {
//     spectator = createComponent();
//     packageDetailsListStore = spectator.inject(PackageDetailsListStore, true);
//   });

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

//   describe('items(): PackageItemDTO[]', () => {
//     it('should return items', () => {
//       const items = [{ id: '1' }, { id: '2' }] as PackageItemDTO[];
//       spyOnProperty(packageDetailsListStore, 'items', 'get').and.returnValue(items);
//       expect(spectator.component.items).toEqual(items);
//     });

//     it('should not call patchState and loadStockInfos when items are set to the same value', () => {
//       const items = [{ id: '1' }, { id: '2' }] as PackageItemDTO[];
//       spyOnProperty(spectator.component, 'items', 'get').and.returnValue(items);
//       const setItemsSpy = spyOn(packageDetailsListStore, 'setItems');

//       spectator.component.items = items;

//       expect(setItemsSpy).not.toHaveBeenCalled();
//     });
//   });

//   describe('arrivalStatus(): number', () => {
//     it('should return arrivalStatus', () => {
//       const arrivalStatus = 1;
//       spyOnProperty(packageDetailsListStore, 'arrivalStatus', 'get').and.returnValue(arrivalStatus);
//       expect(spectator.component.arrivalStatus).toEqual(arrivalStatus);
//     });

//     it('should call store.setArrivalStatus when arrivalStatus is set', () => {
//       const arrivalStatus = 1;
//       const setArrivalStatusSpy = spyOn(packageDetailsListStore, 'setArrivalStatus');
//       spectator.component.arrivalStatus = arrivalStatus;
//       expect(setArrivalStatusSpy).toHaveBeenCalledWith(arrivalStatus);
//     });

//     it('should not call patchState when arrivalStatus is set to the same value', () => {
//       const arrivalStatus = 1;
//       spyOnProperty(spectator.component, 'arrivalStatus', 'get').and.returnValue(arrivalStatus);
//       const setArrivalStatusSpy = spyOn(packageDetailsListStore, 'setArrivalStatus');

//       spectator.component.arrivalStatus = arrivalStatus;

//       expect(setArrivalStatusSpy).not.toHaveBeenCalled();
//     });
//   });

//   describe('trackByItemId(index: number, item: PackageItemDTO): string', () => {
//     it('should return trageByItemId', () => {
//       const item = { id: '1' } as PackageItemDTO;
//       expect(spectator.component.trackByItemId(1, item)).toEqual(item.id);
//     });

//     it('should return undefined when item is undefined', () => {
//       expect(spectator.component.trackByItemId(1, undefined)).toBeUndefined();
//     });
//   });

//   describe('.page-package-details-list__items-count', () => {
//     it('should display the number of items', fakeAsync(() => {
//       const items = [{ id: '1' }, { id: '2' }] as PackageItemDTO[];
//       spectator.component.items$ = of(items);
//       spectator.detectComponentChanges();
//       spectator.tick();
//       const itemsCount = spectator.query('.page-package-details-list__items-count');
//       expect(itemsCount.textContent).toContain('2');
//     }));
//   });

//   describe('page-package-details-list-item', () => {
//     it('should render a page-package-details-list-item for each item', fakeAsync(() => {
//       const items = [{ id: '1' }, { id: '2' }] as PackageItemDTO[];
//       spectator.component.items$ = of(items);
//       // Render Range muss gesetzt werden, da sonst keine Items gerendert werden
//       spectator.query(CdkVirtualScrollViewport).setRenderedRange({ start: 0, end: 10 });

//       spectator.detectComponentChanges();
//       spectator.tick();

//       const itemsCount = spectator.queryAll(PackageDetailsListItemComponent);
//       expect(itemsCount.length).toEqual(2);
//       expect(itemsCount[0].item).toEqual(items[0]);
//       expect(itemsCount[1].item).toEqual(items[1]);
//     }));
//   });
// });
