Skip to content

Commit

Permalink
#2004 - Removed unit test for router from educational material
Browse files Browse the repository at this point in the history
  • Loading branch information
Brajesh Kumar authored and Brajesh Kumar committed Oct 12, 2023
1 parent cc6d697 commit 580fbb9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</app-entity-subrecord>

<div class="margin-top-large">
<ng-container *ngFor="let item of summary">
<ng-container *ngFor="let item of summaries">
<ng-container *ngIf="item.total">
<strong>Total:</strong> {{ totalSummary }} <br>
<strong>Total:</strong> {{ summary }} <br>
</ng-container>
<ng-container *ngIf="item.average">
<strong>Average:</strong> {{ avgSummary }} <br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { MockedTestingModule } from "../../../../utils/mocked-testing.module";
import { EducationalMaterial } from "../model/educational-material";
import { ConfigurableEnumValue } from "../../../../core/basic-datatypes/configurable-enum/configurable-enum.interface";
import { EntityMapperService } from "../../../../core/entity/entity-mapper/entity-mapper.service";
import { of, Subject } from "rxjs";
import { Subject } from "rxjs";
import { UpdatedEntity } from "../../../../core/entity/model/entity-update";
import { ActivatedRoute } from "@angular/router";

describe("EducationalMaterialComponent", () => {
let component: EducationalMaterialComponent;
Expand All @@ -27,33 +26,7 @@ describe("EducationalMaterialComponent", () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [EducationalMaterialComponent, MockedTestingModule.withState()],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: of({
config: {
entity: "Child",
panels: [
{
title: "Educational Materials",
summary: [
{
Total: "Total",
},
{
Average: "Average",
},
],
},
],
},
}),
},
},
],
}).compileComponents();

const entityMapper = TestBed.inject(EntityMapperService);
spyOn(entityMapper, "receiveUpdates").and.returnValue(updates);
}));
Expand Down Expand Up @@ -123,18 +96,6 @@ describe("EducationalMaterialComponent", () => {
expect(newRecord.child).toBe(child.getId());
});

it("produces an empty summary when there are no records", () => {
component.records = [];
component.updateSummary();
expect(component.summary).toHaveSize(0);
});

it("should set summaryTitle based on panel title", () => {
setRecordsAndGenerateSummary([{ Total: "Total" }, { Average: "Average" }])
component.getSummaryList();
expect(component.summaryTitle).toEqual([{ Total: "Total" }, { Average: "Average" }]);
});

it("should update the summary when entity updates are received", async () => {
const update1 = EducationalMaterial.create({
child: child.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import { ActivatedRoute } from "@angular/router";
standalone: true,
})
export class EducationalMaterialComponent implements OnInit {
@Input() summary: any[];
@Input() summaries: any[];
@Input() entity: Child;
records: EducationalMaterial[] = [];
totalSummary = "";
summary = "";
avgSummary = "";
listConfig: EntityListConfig;

Expand Down Expand Up @@ -115,7 +115,7 @@ export class EducationalMaterialComponent implements OnInit {
return `${label}: ${avg}`;
});

this.totalSummary = summaryArray.join(", ");
this.summary = summaryArray.join(", ");
this.avgSummary = avgSummaryArray.join(", ");
}
}
2 changes: 1 addition & 1 deletion src/app/core/config/config-fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ export const defaultJsonConfig = {
"title": "",
"component": "EducationalMaterial",
"config": {
"summary": [
"summaries": [
{
"type": "boolean",
total: true, average: true
Expand Down

0 comments on commit 580fbb9

Please sign in to comment.