From a02f4447abf44f3a2aa224a363c97df53f3782b4 Mon Sep 17 00:00:00 2001 From: Maureen Chang <76696006+techMedMau@users.noreply.github.com> Date: Tue, 26 Mar 2024 02:21:05 -0700 Subject: [PATCH] [#12588] Improve test code coverage of core components - ViewResultsPanelComponent (#12918) * add test cases to ViewResultsPanelComponent * fix lint errors --------- Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com> Co-authored-by: Zhang Ziqing <69516975+ziqing26@users.noreply.github.com> --- .../view-results-panel.component.spec.ts | 48 +++++++++++++++++++ 1 file changed, 48 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..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,6 +3,12 @@ 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'; @@ -36,4 +42,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); + }); });