Skip to content

Commit 57fba55

Browse files
committed
Add tests
1 parent 6c3a626 commit 57fba55

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2+
import { ActionsMenuComponent } from './actions-menu.component';
3+
import { UserPreferencesService } from 'src/app/core/user-preferences.service';
4+
import { MatMenuModule } from '@angular/material/menu';
5+
6+
class UserPreferencesMock {
7+
userInfo = {
8+
roles: ["roles"]
9+
10+
}
11+
}
12+
13+
describe('ActionsMenuComponent', () => {
14+
let component: ActionsMenuComponent;
15+
let fixture: ComponentFixture<ActionsMenuComponent>;
16+
17+
beforeEach(waitForAsync(() => {
18+
TestBed.configureTestingModule({
19+
declarations: [ActionsMenuComponent],
20+
imports: [MatMenuModule],
21+
providers: [
22+
{ provide: UserPreferencesService, useClass: UserPreferencesMock },
23+
]
24+
})
25+
.compileComponents();
26+
}));
27+
28+
beforeEach(() => {
29+
fixture = TestBed.createComponent(ActionsMenuComponent);
30+
component = fixture.componentInstance;
31+
fixture.detectChanges();
32+
});
33+
34+
it('should create', () => {
35+
expect(component).toBeTruthy();
36+
});
37+
38+
it('should enableActions', () => {
39+
const isAllowedSpy = spyOn(component['isAllowedService'], 'isAnyEditAllowed');
40+
component['enableActions']();
41+
expect(isAllowedSpy).toHaveBeenCalledTimes(1);
42+
});
43+
44+
});

scilog/src/app/overview/logbook-cover/logbook-cover.component.spec.ts

-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { LogbookItemDataService } from '@shared/remote-data.service';
44
import { UserPreferencesService } from '@shared/user-preferences.service';
55
import { LogbookInfoService } from '@shared/logbook-info.service';
66
import { of } from 'rxjs';
7-
import { MatLegacyMenuModule as MatMenuModule } from '@angular/material/legacy-menu';
87
import { Logbooks } from '@model/logbooks';
98

109
class UserPreferencesMock {
@@ -54,7 +53,6 @@ describe('LogbookWidgetComponent', () => {
5453
{provide: UserPreferencesService, useClass: UserPreferencesMock},
5554
{provide: LogbookItemDataService, useValue: logbookItemDataSpy},
5655
],
57-
imports: [MatMenuModule],
5856
declarations: [ LogbookWidgetComponent ]
5957
})
6058
.compileComponents();
@@ -72,10 +70,4 @@ describe('LogbookWidgetComponent', () => {
7270
expect(component).toBeTruthy();
7371
});
7472

75-
it('should test enableActions', () => {
76-
const isAnyEditAllowedSpy = spyOn(component['isActionAllowed'], 'isAnyEditAllowed');
77-
component['enableActions']();
78-
expect(isAnyEditAllowedSpy).toHaveBeenCalledTimes(1);
79-
});
80-
8173
});

0 commit comments

Comments
 (0)