Skip to content

Commit

Permalink
fix(deps): coverage for file even with no hostlisteners for example
Browse files Browse the repository at this point in the history
fix #527
  • Loading branch information
vogloblinsky committed Apr 2, 2018
1 parent fc960b7 commit c7a3264
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 26 deletions.
73 changes: 47 additions & 26 deletions src/app/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,16 +1442,25 @@ export class Application {
return status;
};
let processComponentsAndDirectives = list => {
_.forEach(list, (element: any) => {
if (
!element.propertiesClass ||
!element.methodsClass ||
!element.hostBindings ||
!element.hostListeners ||
!element.inputsClass ||
!element.outputsClass
) {
return;
_.forEach(list, (el: any) => {
let element = (Object as any).assign({}, el);
if (!element.propertiesClass) {
element.propertiesClass = [];
}
if (!element.methodsClass) {
element.methodsClass = [];
}
if (!element.hostBindings) {
element.hostBindings = [];
}
if (!element.hostListeners) {
element.hostListeners = [];
}
if (!element.inputsClass) {
element.inputsClass = [];
}
if (!element.outputsClass) {
element.outputsClass = [];
}
let cl: any = {
filePath: element.file,
Expand Down Expand Up @@ -1645,11 +1654,15 @@ export class Application {
processComponentsAndDirectives(this.configuration.mainData.components);
processComponentsAndDirectives(this.configuration.mainData.directives);

_.forEach(this.configuration.mainData.classes, (classe: any) => {
if (!classe.properties || !classe.methods) {
return;
_.forEach(this.configuration.mainData.classes, (cl: any) => {
let classe = (Object as any).assign({}, cl);
if (!classe.properties) {
classe.properties = [];
}
let cl: any = {
if (!classe.methods) {
classe.methods = [];
}
let cla: any = {
filePath: classe.file,
type: 'class',
linktype: 'classe',
Expand Down Expand Up @@ -1699,18 +1712,22 @@ export class Application {
}
});

cl.coveragePercent = Math.floor(totalStatementDocumented / totalStatements * 100);
cla.coveragePercent = Math.floor(totalStatementDocumented / totalStatements * 100);
if (totalStatements === 0) {
cl.coveragePercent = 0;
cla.coveragePercent = 0;
}
cl.coverageCount = totalStatementDocumented + '/' + totalStatements;
cl.status = getStatus(cl.coveragePercent);
totalProjectStatementDocumented += cl.coveragePercent;
files.push(cl);
cla.coverageCount = totalStatementDocumented + '/' + totalStatements;
cla.status = getStatus(cla.coveragePercent);
totalProjectStatementDocumented += cla.coveragePercent;
files.push(cla);
});
_.forEach(this.configuration.mainData.injectables, (injectable: any) => {
if (!injectable.properties || !injectable.methods) {
return;
_.forEach(this.configuration.mainData.injectables, (inj: any) => {
let injectable = (Object as any).assign({}, inj);
if (!injectable.properties) {
injectable.properties = [];
}
if (!injectable.methods) {
injectable.methods = [];
}
let cl: any = {
filePath: injectable.file,
Expand Down Expand Up @@ -1771,9 +1788,13 @@ export class Application {
totalProjectStatementDocumented += cl.coveragePercent;
files.push(cl);
});
_.forEach(this.configuration.mainData.interfaces, (inter: any) => {
if (!inter.properties || !inter.methods) {
return;
_.forEach(this.configuration.mainData.interfaces, (inte: any) => {
let inter = (Object as any).assign({}, inte);
if (!inter.properties) {
inter.properties = [];
}
if (!inter.methods) {
inter.methods = [];
}
let cl: any = {
filePath: inter.file,
Expand Down
5 changes: 5 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,9 @@ describe('CLI simple generation - big app', () => {
expect(file).to.contain('(test/.../miscellaneous.ts)');
expect(file).to.contain('title="test/src/todomvc-ng2/src/app/shared/miscellaneous/miscellaneous.ts"');
});

it('should display component even with no hostlisteners', () => {
let file = read(distFolder + '/coverage.html');
expect(file).to.contain('test/src/todomvc-ng2/src/app/footer/footer.component.ts');
});
});

0 comments on commit c7a3264

Please sign in to comment.