// import { Spectator, createComponentFactory } from '@ngneat/spectator';
// import { ShellSideMenuComponent } from './side-menu.component';
// import { ShellService } from '../shell.service';
// import { AuthService } from '@core/auth';
// import { StockService } from '@generated/swagger/wws-api';
// import { ApplicationProcess, ApplicationService } from '@core/application';
// import { WrongDestinationModalService } from '@shared/modals/wrong-destination-modal';
// import { of } from 'rxjs';
// import { RouterTestingModule } from '@angular/router/testing';
// import { Router } from '@angular/router';
// import { ProductCatalogNavigationService } from '@shared/services/navigation';
// import { Config } from '@core/config';
// import { BreadcrumbService } from '@core/breadcrumb';
// import { EmptyIconLoader, IconLoader, provideIcon } from '@shared/components/icon';
// import { UiModalService } from '@ui/modal';

// describe('ShellSideMenuComponent', () => {
//   let spectator: Spectator<ShellSideMenuComponent>;
//   let catalogNavigationService: jasmine.SpyObj<ProductCatalogNavigationService>;
//   const createComponent = createComponentFactory({
//     component: ShellSideMenuComponent,
//     imports: [RouterTestingModule],
//     mocks: [ShellService, AuthService, WrongDestinationModalService, Config, BreadcrumbService, UiModalService],
//     providers: [
//       provideIcon({ provide: IconLoader, useClass: EmptyIconLoader }),
//       {
//         provide: ApplicationService,
//         useValue: jasmine.createSpyObj<ApplicationService>(
//           'ApplicationService',
//           {
//             getSection$: of('customer'),
//             getProcesses$: of([]),
//             getProcessById$: of(undefined),
//             createProcess: Promise.resolve(),
//             removeProcess: undefined,
//           },
//           { activatedProcessId$: of(undefined) },
//         ),
//       },
//       {
//         provide: StockService,
//         useValue: jasmine.createSpyObj(StockService, {
//           StockCurrentBranch: of({ result: { key: 'test' } }),
//         }),
//       },
//     ],
//   });

//   beforeEach(() => {
//     catalogNavigationService = jasmine.createSpyObj<ProductCatalogNavigationService>(['getArticleSearchBasePath']);

//     spectator = createComponent({
//       providers: [
//         {
//           provide: ProductCatalogNavigationService,
//           useValue: catalogNavigationService,
//         },
//       ],
//     });
//   });

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

//   describe('closeSideMenu()', () => {
//     it('should call shellService.closeSideMenu', () => {
//       const shellService = spectator.inject(ShellService);
//       spectator.component.closeSideMenu();
//       expect(shellService.closeSideMenu).toHaveBeenCalled();
//     });
//   });

//   describe('logout()', () => {
//     it('should call authService.logout', () => {
//       const authService = spectator.inject(AuthService);
//       spectator.component.logout();
//       expect(authService.logout).toHaveBeenCalled();
//     });
//   });

//   describe('createProcess()', () => {
//     it('should call this.createCartProcess and this.navigateToCatalog with the created process', async () => {
//       const process: ApplicationProcess = { id: 1, name: '', section: 'customer' };
//       const spy = spyOn(spectator.component, 'createCartProcess').and.returnValue(Promise.resolve(process));
//       const spy2 = spyOn(spectator.component, 'navigateToCatalog');
//       await spectator.component.createProcess();
//       expect(spy).toHaveBeenCalled();
//       expect(spy2).toHaveBeenCalledWith(process);
//     });
//   });

//   describe('createCartProcess()', () => {
//     it('should create a new process and return it', async () => {
//       const applicationService = spectator.inject(ApplicationService);
//       spyOn(spectator.component, 'getNextProcessName').and.returnValue(Promise.resolve('Vorgang 3'));
//       spyOn(spectator.component, 'getNextProcessId').and.returnValue(123);

//       const expected: ApplicationProcess = {
//         id: 123,
//         name: 'Vorgang 3',
//         section: 'customer',
//         type: 'cart',
//         closeable: true,
//       };

//       const result = await spectator.component.createCartProcess();

//       expect(applicationService.createProcess).toHaveBeenCalledWith(expected);
//       expect(result).toEqual(expected);
//     });
//   });

//   describe('getNextProcessName()', () => {
//     it('should return the next process name by getting all "customer" processes and filter by type "cart" and name starting with "Vorgang " returns the next higher number', async () => {
//       const applicationService = spectator.inject(ApplicationService);
//       (applicationService.getProcesses$ as jasmine.Spy).and.returnValue(
//         of([
//           { id: 1, name: 'Vorgang 1', section: 'customer', type: 'cart' },
//           { id: 2, name: 'Vorgang 2', section: 'customer', type: 'cart' },
//           { id: 3, name: 'Vorgang 3', section: 'customer', type: 'cart' },
//           { id: 4, name: 'Unit Test', section: 'customer', type: 'cart' },
//         ]),
//       );
//       const result = await spectator.component.getNextProcessName();
//       expect(result).toEqual('Vorgang 4');
//     });
//   });

//   describe('getNextProcessId()', () => {
//     it('should return the next process id using Date.now()', () => {
//       const result = spectator.component.getNextProcessId();
//       expect(result).toEqual(Date.now());
//     });
//   });

//   describe('navigateToCatalog(process: ApplicationProcess)', () => {
//     it('should call Router.navigate with  ["/kunde", <process.id>, "product", "search"]', () => {
//       const process: ApplicationProcess = { id: 1, name: '', section: 'customer' };

//       spectator.component.navigateToCatalog(process);

//       expect(catalogNavigationService.getArticleSearchBasePath).toHaveBeenCalledWith(process.id);
//     });
//   });

//   describe('navigateToDashboard()', () => {
//     it('should call Router.navigate with ["/kunde", "dashboard"]', () => {
//       const router = spectator.inject(Router);
//       const spy = spyOn(router, 'navigate');
//       spectator.component.navigateToDashboard();
//       expect(spy).toHaveBeenCalledWith(['/kunde', 'dashboard']);
//     });
//   });

//   describe('closeAllProcesses()', () => {
//     it('should get processes$ and iterate over them and call applicationService.removeProcess with the process id ', async () => {
//       const applicationService = spectator.inject(ApplicationService);
//       spectator.component.processes$ = of([
//         { id: 1, name: 'Vorgang 1', section: 'customer', type: 'cart' },
//         { id: 2, name: 'Vorgang 2', section: 'customer', type: 'cart' },
//         { id: 3, name: 'Vorgang 3', section: 'customer', type: 'cart' },
//         { id: 4, name: 'Unit Test', section: 'customer', type: 'cart' },
//       ]);

//       spyOn(spectator.component, 'navigateToDashboard');

//       await spectator.component.closeAllProcesses();
//       expect(applicationService.removeProcess).toHaveBeenCalledWith(1);
//       expect(applicationService.removeProcess).toHaveBeenCalledWith(2);
//       expect(applicationService.removeProcess).toHaveBeenCalledWith(3);
//       expect(applicationService.removeProcess).toHaveBeenCalledWith(4);

//       expect(spectator.component.navigateToDashboard).toHaveBeenCalled();
//     });
//   });

//   describe('fetchAndOpenPackages()', () => {
//     it('shuld call WrongDestinationModalService.fetchAndOpen()', () => {
//       const wrongDestinationModalService = spectator.inject(WrongDestinationModalService);
//       spectator.component.fetchAndOpenPackages();
//       expect(wrongDestinationModalService.fetchAndOpen).toHaveBeenCalled();
//     });
//   });
// });
