Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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],
declarations: [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();
});
});