Fix Unit Sests ShellSideMenuComponent

This commit is contained in:
Lorenz Hilpert
2023-05-25 16:12:08 +02:00
parent 6801e3858a
commit 4961fb9756

View File

@@ -6,10 +6,8 @@ import { StockService } from '@swagger/wws';
import { ApplicationProcess, ApplicationService } from '@core/application';
import { WrongDestinationModalService } from '@shared/modals/wrong-destination-modal';
import { of } from 'rxjs';
import { IfRoleDirective } from 'apps/core/auth/src/lib/if-role.directive';
import { MockComponents, MockDirectives } from 'ng-mocks';
import { RouterTestingModule } from '@angular/router/testing';
import { UISvgIconComponent, UiIconComponent } from '@ui/icon';
import { IconRegistry } from '@ui/icon';
import { Router } from '@angular/router';
import { ProductCatalogNavigationService } from '@shared/services';
@@ -19,8 +17,7 @@ describe('ShellSideMenuComponent', () => {
const createComponent = createComponentFactory({
component: ShellSideMenuComponent,
imports: [RouterTestingModule],
mocks: [ShellService, AuthService, WrongDestinationModalService],
declarations: [MockDirectives(IfRoleDirective), MockComponents(UISvgIconComponent, UiIconComponent, UISvgIconComponent)],
mocks: [ShellService, AuthService, WrongDestinationModalService, IconRegistry],
providers: [
{
provide: ApplicationService,
@@ -181,68 +178,4 @@ describe('ShellSideMenuComponent', () => {
expect(wrongDestinationModalService.fetchAndOpen).toHaveBeenCalled();
});
});
describe('template', () => {
// describe('.create-process-btn should call createProcess()', () => {
// it('should call createProcess()', () => {
// const spy = spyOn(spectator.component, 'createProcess');
// spectator.click('.create-process-btn');
// expect(spy).toHaveBeenCalled();
// });
// });
describe('nav.customer-section', () => {
it('should render a nav.customer-section when section$ returns "customer"', () => {
spectator.setInput({ section$: of('customer') });
expect(spectator.query('nav.customer-section')).toBeTruthy();
});
it('should not render a nav.customer-section when section$ returns "branch"', () => {
spectator.setInput({ section$: of('branch') });
expect(spectator.query('nav.customer-section')).toBeFalsy();
});
});
describe('nav.branch-section', () => {
it('should render a nav.branch-section when section$ returns "branch"', () => {
spectator.setInput({ section$: of('branch') });
expect(spectator.query('nav.branch-section')).toBeTruthy();
});
it('should not render a nav.branch-section when section$ returns "customer"', () => {
spectator.setInput({ section$: of('customer') });
expect(spectator.query('nav.branch-section')).toBeFalsy();
});
});
describe('.close-all-processes-btn', () => {
it('should call closeAllProcesses() when clicked', () => {
const spy = spyOn(spectator.component, 'closeAllProcesses');
spectator.click('.close-all-processes-btn');
expect(spy).toHaveBeenCalled();
});
it('should render the process count', () => {
spectator.component.processesCount$ = of<any>(3);
spectator.detectComponentChanges();
expect(spectator.query('.close-all-processes-btn .isa-label').textContent).toContain('3');
});
});
describe('.dashboard-btn', () => {
it('should call closeSideMenu() when clicked', () => {
const spy = spyOn(spectator.component, 'closeSideMenu');
spectator.click('.dashboard-btn');
expect(spy).toHaveBeenCalled();
});
});
describe('.logout-btn', () => {
it('should call logout() when clicked', () => {
const spy = spyOn(spectator.component, 'logout');
spectator.click('.logout-btn');
expect(spy).toHaveBeenCalled();
});
});
});
});