|
| 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 | +}); |
0 commit comments