From 396dff66914dc50ec7bcb1f11f4610175b4e5f4c Mon Sep 17 00:00:00 2001 From: justincavalli <81125835+justincavalli@users.noreply.github.com> Date: Mon, 29 May 2023 01:46:12 -0700 Subject: [PATCH] [#10920] Add test for restoreCourse in Instructor Courses Page (#12443) * Add test for restoring a course on instructor course page * remove trailing white space --------- Co-authored-by: Jason Qiu --- .../instructor-courses-page.component.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.spec.ts b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.spec.ts index fb0be669861..0f5bfef5877 100644 --- a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.spec.ts +++ b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.spec.ts @@ -385,6 +385,24 @@ describe('InstructorCoursesPageComponent', () => { expect(component.activeCourses[0].course.courseId).toEqual('CS1231'); }); + it('should restore a soft deleted course', () => { + component.softDeletedCourses = [courseModelCS1231]; + expect(component.softDeletedCourses.length).toEqual(1); + + const courseSpy: SpyInstance = jest.spyOn(courseService, 'restoreCourse') + .mockReturnValue(of(courseModelCS1231)); + jest.spyOn(simpleModalService, 'openConfirmationModal') + .mockReturnValue(createMockNgbModalRef()); + + component.onRestore('CS1231'); + + expect(courseSpy).toHaveBeenCalledTimes(1); + expect(courseSpy).toHaveBeenNthCalledWith(1, 'CS1231'); + + expect(component.archivedCourses.length).toEqual(0); + expect(component.softDeletedCourses.length).toEqual(0); +}); + it('should soft delete a course', async () => { component.activeCourses = [courseModelCS1231]; const courseSpy: SpyInstance = jest.spyOn(courseService, 'binCourse').mockReturnValue(of(courseCS1231));