Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Nov 18, 2024
1 parent 8bde0e1 commit 44de16c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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<ActionsMenuComponent>;
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);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});

0 comments on commit 44de16c

Please sign in to comment.