Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12588] Improve test code coverage of core components - ViewResultsPanelComponent #12918

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);
});
});
Loading