isdashboard/src/main/webapp/app/layouts/profiles/page-ribbon.component.spec.ts

40 lines
1.2 KiB
TypeScript
Executable File

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { ProfileInfo } from 'app/layouts/profiles/profile-info.model';
import { ProfileService } from 'app/layouts/profiles/profile.service';
import PageRibbonComponent from './page-ribbon.component';
describe('Page Ribbon Component', () => {
let comp: PageRibbonComponent;
let fixture: ComponentFixture<PageRibbonComponent>;
let profileService: ProfileService;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, PageRibbonComponent],
})
.overrideTemplate(PageRibbonComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PageRibbonComponent);
comp = fixture.componentInstance;
profileService = TestBed.inject(ProfileService);
});
it('Should call profileService.getProfileInfo on init', () => {
// GIVEN
jest.spyOn(profileService, 'getProfileInfo').mockReturnValue(of(new ProfileInfo()));
// WHEN
comp.ngOnInit();
// THEN
expect(profileService.getProfileInfo).toHaveBeenCalled();
});
});