From 5ec9564a71b8abda5204ba092f4c617f8f62d5fd Mon Sep 17 00:00:00 2001 From: justincavalli <81125835+justincavalli@users.noreply.github.com> Date: Mon, 22 May 2023 16:51:55 -0700 Subject: [PATCH 1/2] Add test for restoring a course on instructor course page --- .../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..8244cf12670 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 @@ -384,6 +384,24 @@ describe('InstructorCoursesPageComponent', () => { expect(component.activeCourses.length).toEqual(1); 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]; From 37f713175e6279d63cdb1cbb2d22dfefd618b5a2 Mon Sep 17 00:00:00 2001 From: justincavalli <81125835+justincavalli@users.noreply.github.com> Date: Mon, 22 May 2023 17:43:44 -0700 Subject: [PATCH 2/2] remove trailing white space --- .../instructor-courses-page.component.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 8244cf12670..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 @@ -384,7 +384,7 @@ describe('InstructorCoursesPageComponent', () => { expect(component.activeCourses.length).toEqual(1); expect(component.activeCourses[0].course.courseId).toEqual('CS1231'); }); - + it('should restore a soft deleted course', () => { component.softDeletedCourses = [courseModelCS1231]; expect(component.softDeletedCourses.length).toEqual(1); @@ -393,15 +393,15 @@ describe('InstructorCoursesPageComponent', () => { .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); - }); + expect(component.softDeletedCourses.length).toEqual(0); +}); it('should soft delete a course', async () => { component.activeCourses = [courseModelCS1231];