From b16dbb43baa0ce1c1c0ffccdb1b847a9437108ea Mon Sep 17 00:00:00 2001 From: Maureen Chang <76696006+techMedMau@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:30:15 -0700 Subject: [PATCH 1/2] add test cases to ViewResultsPanelComponent --- .../view-results-panel.component.spec.ts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts b/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts index 338537d863b..8e545c1dafe 100644 --- a/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts +++ b/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts @@ -7,6 +7,8 @@ import { SectionTypeDescriptionModule, } from '../../pages-instructor/instructor-session-result-page/section-type-description.module'; import { TeammatesCommonModule } from '../teammates-common/teammates-common.module'; +import { InstructorSessionResultViewType } from '../../pages-instructor/instructor-session-result-page/instructor-session-result-view-type.enum'; +import { InstructorSessionResultSectionType } from '../../pages-instructor/instructor-session-result-page/instructor-session-result-section-type.enum'; describe('ViewResultsPanelComponent', () => { let component: ViewResultsPanelComponent; @@ -36,4 +38,46 @@ describe('ViewResultsPanelComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should emit viewTypeChange event when handleViewTypeChange is called', () => { + const newViewType = InstructorSessionResultViewType.GRQ; + const spy = jest.spyOn(component.viewTypeChange, 'emit'); + component.handleViewTypeChange(newViewType); + expect(spy).toHaveBeenCalledWith(newViewType); + }); + + it('should emit sectionChange event when handleSectionChange is called', () => { + const newSection = 'newSection'; + const spy = jest.spyOn(component.sectionChange, 'emit'); + component.handleSectionChange(newSection); + expect(spy).toHaveBeenCalledWith(newSection); + }); + + it('should emit sectionTypeChange event when handleSectionTypeChange is called', () => { + const newSectionType = InstructorSessionResultSectionType.EITHER; + const spy = jest.spyOn(component.sectionTypeChange, 'emit'); + component.handleSectionTypeChange(newSectionType); + expect(spy).toHaveBeenCalledWith(newSectionType); + }); + + it('should emit groupByTeamChange event when handleGroupByTeamChange is called', () => { + const newGroupByTeam = false; + const spy = jest.spyOn(component.groupByTeamChange, 'emit'); + component.handleGroupByTeamChange(newGroupByTeam); + expect(spy).toHaveBeenCalledWith(newGroupByTeam); + }); + + it('should emit showStatisticsChange event when handleShowStatisticsChange is called', () => { + const newShowStatistics = false; + const spy = jest.spyOn(component.showStatisticsChange, 'emit'); + component.handleShowStatisticsChange(newShowStatistics); + expect(spy).toHaveBeenCalledWith(newShowStatistics); + }); + + it('should emit indicateMissingResponsesChange event when handleIndicateMissingResponsesChange is called', () => { + const newIndicateMissingResponsesChange = false; + const spy = jest.spyOn(component.indicateMissingResponsesChange, 'emit'); + component.handleIndicateMissingResponsesChange(newIndicateMissingResponsesChange); + expect(spy).toHaveBeenCalledWith(newIndicateMissingResponsesChange); + }); }); From f1ccd714f7b046d96173291c4f39cbecea0ea68f Mon Sep 17 00:00:00 2001 From: Maureen Chang <76696006+techMedMau@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:20:04 -0700 Subject: [PATCH 2/2] fix lint errors --- .../view-results-panel.component.spec.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts b/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts index 8e545c1dafe..9e4e9036065 100644 --- a/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts +++ b/src/web/app/components/view-results-panel/view-results-panel.component.spec.ts @@ -3,12 +3,16 @@ import { FormsModule } from '@angular/forms'; import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; import { ViewResultsPanelComponent } from './view-results-panel.component'; +import { + InstructorSessionResultSectionType, +} from '../../pages-instructor/instructor-session-result-page/instructor-session-result-section-type.enum'; +import { + InstructorSessionResultViewType, +} from '../../pages-instructor/instructor-session-result-page/instructor-session-result-view-type.enum'; import { SectionTypeDescriptionModule, } from '../../pages-instructor/instructor-session-result-page/section-type-description.module'; import { TeammatesCommonModule } from '../teammates-common/teammates-common.module'; -import { InstructorSessionResultViewType } from '../../pages-instructor/instructor-session-result-page/instructor-session-result-view-type.enum'; -import { InstructorSessionResultSectionType } from '../../pages-instructor/instructor-session-result-page/instructor-session-result-section-type.enum'; describe('ViewResultsPanelComponent', () => { let component: ViewResultsPanelComponent; @@ -59,25 +63,25 @@ describe('ViewResultsPanelComponent', () => { component.handleSectionTypeChange(newSectionType); expect(spy).toHaveBeenCalledWith(newSectionType); }); - + it('should emit groupByTeamChange event when handleGroupByTeamChange is called', () => { const newGroupByTeam = false; const spy = jest.spyOn(component.groupByTeamChange, 'emit'); component.handleGroupByTeamChange(newGroupByTeam); expect(spy).toHaveBeenCalledWith(newGroupByTeam); }); - + it('should emit showStatisticsChange event when handleShowStatisticsChange is called', () => { const newShowStatistics = false; const spy = jest.spyOn(component.showStatisticsChange, 'emit'); component.handleShowStatisticsChange(newShowStatistics); expect(spy).toHaveBeenCalledWith(newShowStatistics); }); - + it('should emit indicateMissingResponsesChange event when handleIndicateMissingResponsesChange is called', () => { const newIndicateMissingResponsesChange = false; const spy = jest.spyOn(component.indicateMissingResponsesChange, 'emit'); component.handleIndicateMissingResponsesChange(newIndicateMissingResponsesChange); expect(spy).toHaveBeenCalledWith(newIndicateMissingResponsesChange); - }); + }); });