I have written a few functions within the app component. I am experiencing an issue with increasing coverage in the summary for these component methods.
The test cases are functioning correctly, but some lines are not being accounted for in the coverage summary.
app.component.ts
public initializeA(): void {
this.flagClone.client = {
build: null, //string
name: null, //string
id: null //string
}
}
public initializeB(): FlagResult {
this.isSearch = false;
return {
id: null, //string
description: null, //string
url: null, //string
client:{
build: null, //string
name: null, //string
id: null //string
}
};
}
app.component.spec.ts corresponding test cases
const testFlagResult: FlagResult = {
id: null, //string
description: null, //string
url: null, //string
client:{
build: null, //string
name: null, //string
id: null //string
}
};
it('should initializeA',() => {
const mock = spyOn(component,'initializeA').and.returnValue();
component.initializeA();
fixture.detectChanges();
expect(mock).toHaveBeenCalled();
});
it('should initializeB',() => {
const mock = spyOn(component,'initializeB').and.returnValue(testFlagResult);
component.initializeB();
fixture.detectChanges();
expect(component.isSearch).toBeTruthy();
expect(mock).toHaveBeenCalled();
});
I'm hoping to see the following block included in the coverage summary:
public initializeA(): void {
this.flagClone.client = {
public initializeB(): FlagResult {
this.isSearch = false;
Any insights on where I may be missing out?