From 6604a0c3504da8f42b4176fec9fb34b9fe286bd1 Mon Sep 17 00:00:00 2001 From: Cedric Ong Date: Mon, 11 Sep 2023 00:21:24 +0800 Subject: [PATCH] add-initial-test --- ...instructor-sessions-page.component.spec.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/web/app/pages-instructor/instructor-sessions-page/instructor-sessions-page.component.spec.ts b/src/web/app/pages-instructor/instructor-sessions-page/instructor-sessions-page.component.spec.ts index c835896b783..be1db2fab14 100644 --- a/src/web/app/pages-instructor/instructor-sessions-page/instructor-sessions-page.component.spec.ts +++ b/src/web/app/pages-instructor/instructor-sessions-page/instructor-sessions-page.component.spec.ts @@ -3,7 +3,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; +import { of, Observable } from 'rxjs'; import SpyInstance = jest.SpyInstance; import { CourseService } from '../../../services/course.service'; import { FeedbackSessionsService } from '../../../services/feedback-sessions.service'; @@ -429,4 +429,22 @@ describe('InstructorSessionsPageComponent', () => { expect(fixture).toMatchSnapshot(); }); + it('should call copySingleSession when requestList contains only one item', () => { + const result = { + sessionToCopyRowIndex: 0, + newFeedbackSessionName: 'New feedback session', + copyToCourseList: [], + sessionToCopyCourseId: '1' + } + const mockRequest = of({} as FeedbackSession) + jest.spyOn(component, 'createSessionCopyRequestsFromRowModel').mockReturnValue([mockRequest]); + const copySingleSessionSpy = jest.spyOn(component, 'copySingleSession'); + + component.copySessionEventHandler(result); + + expect(component.createSessionCopyRequestsFromRowModel).toHaveBeenCalled(); + expect(copySingleSessionSpy).toHaveBeenCalledWith(expect.any(Observable), component.modifiedTimestampsModal); + expect(component.isCopyOtherSessionLoading).toBeFalsy() + }); + });