Skip to content

Commit

Permalink
[#10920] Add test for restoreCourse in Instructor Courses Page (#12443)
Browse files Browse the repository at this point in the history
* Add test for restoring a course on instructor course page

* remove trailing white space

---------

Co-authored-by: Jason Qiu <[email protected]>
  • Loading branch information
justincavalli and jasonqiu212 authored May 29, 2023
1 parent 5b091c2 commit 396dff6
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 396dff6

Please sign in to comment.