From 44de16c77f9dfe908086315fb7f3dc80079fff29 Mon Sep 17 00:00:00 2001 From: minottic Date: Mon, 18 Nov 2024 16:10:02 +0100 Subject: [PATCH] Add tests --- .../actions-menu.component.spec.ts | 40 +++++++++++++++++++ .../logbook-cover.component.spec.ts | 6 --- 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 scilog/src/app/overview/actions-menu/actions-menu.component.spec.ts diff --git a/scilog/src/app/overview/actions-menu/actions-menu.component.spec.ts b/scilog/src/app/overview/actions-menu/actions-menu.component.spec.ts new file mode 100644 index 00000000..6e2693c3 --- /dev/null +++ b/scilog/src/app/overview/actions-menu/actions-menu.component.spec.ts @@ -0,0 +1,40 @@ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { MatPaginatorModule } from '@angular/material/paginator'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { ActionsMenuComponent } from './actions-menu.component'; +import { IsAllowedService } from '../is-allowed.service'; + +describe('ActionsMenuComponent', () => { + let component: ActionsMenuComponent; + let fixture: ComponentFixture; + const isAllowedSpy = jasmine.createSpyObj('IsAllowedService', ['isAnyEditAllowed']); + + + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ActionsMenuComponent], + imports: [MatPaginatorModule, NoopAnimationsModule], + providers: [ + { provide: IsAllowedService, useValue: isAllowedSpy }, + ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ActionsMenuComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should enableActions', () => { + component['enableActions'](); + expect(isAllowedSpy.isAnyEditAllowed).toHaveBeenCalledTimes(1); + }); + +}); diff --git a/scilog/src/app/overview/logbook-cover/logbook-cover.component.spec.ts b/scilog/src/app/overview/logbook-cover/logbook-cover.component.spec.ts index 12becaef..484ba59e 100644 --- a/scilog/src/app/overview/logbook-cover/logbook-cover.component.spec.ts +++ b/scilog/src/app/overview/logbook-cover/logbook-cover.component.spec.ts @@ -72,10 +72,4 @@ describe('LogbookWidgetComponent', () => { expect(component).toBeTruthy(); }); - it('should test enableActions', () => { - const isAnyEditAllowedSpy = spyOn(component['isActionAllowed'], 'isAnyEditAllowed'); - component['enableActions'](); - expect(isAnyEditAllowedSpy).toHaveBeenCalledTimes(1); - }); - });