blob: d8166076534ebafb74d3041d1091006585b8ab7c (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderTabsComponent } from './header-tabs.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { CommonModule } from '@angular/common';
describe('MainComponentComponent', () => {
let component: HeaderTabsComponent;
let fixture: ComponentFixture<HeaderTabsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas:[CUSTOM_ELEMENTS_SCHEMA],
declarations: [ HeaderTabsComponent ],
imports:[HttpClientTestingModule,RouterTestingModule]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HeaderTabsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should test if condition in ngOnInit method',()=>{
component.reportId = ""
component.reportMode=""
component.ngOnInit();
expect(component.finalReportId).toEqual("-1");
expect(component.repMode).toEqual("Create");
expect(component.reportId).toEqual("-1");
expect(component.reportMode).toEqual("Create");
});
it('should test else condition in ngOnInit method',()=>{
component.reportId="Indrijeet";
component.reportMode="kumar";
component.ngOnInit();
expect(component.finalReportId).toEqual(component.reportId);
});
it('should test if condition in ngAfterViewInit method',()=>{
component.reportId = "";
component.reportMode="";
component.ngAfterViewInit();
expect(component.finalReportId).toEqual("-1");
expect(component.repMode).toEqual("Create");
expect(component.reportId).toEqual("-1");
expect(component.reportMode).toEqual("Create");
});
it('should test else condition in ngAfterViewInit method',()=>{
component.reportId="indrijeet";
component.reportMode="kumar";
component.ngAfterViewInit();
expect(component.finalReportId).toEqual(component.reportId)
expect(component.repMode).toEqual(component.reportMode)
});
it('should test ngDoCheck method',()=>{
component.ngDoCheck();
console.log(component.tabChanged);
})
});
|