Skip to content

Commit

Permalink
[#12588] Improve test code coverage of core components - ViewResultsP…
Browse files Browse the repository at this point in the history
…anelComponent (#12918)

* add test cases to ViewResultsPanelComponent

* fix lint errors

---------

Co-authored-by: Dominic Lim <[email protected]>
Co-authored-by: Zhang Ziqing <[email protected]>
  • Loading branch information
3 people committed Mar 26, 2024
1 parent e435f17 commit a02f444
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});

0 comments on commit a02f444

Please sign in to comment.