Skip to content

Commit

Permalink
[#10920] Added test for Instructor Course Edit Page (#12462)
Browse files Browse the repository at this point in the history
* added a test case for instructor-course-edit-page

* addressed lint errors

---------

Co-authored-by: Justin <[email protected]>
Co-authored-by: Dominic Lim <[email protected]>
  • Loading branch information
3 people authored Jun 6, 2023
1 parent e17c33a commit 38341d6
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,34 @@ describe('InstructorCourseEditPageComponent', () => {
expect(component.courseFormModel.course.courseName).toBe('Example Course Changed');
});

it('should update instructor details if SAVE is requested', () => {
jest.spyOn(instructorService, 'loadInstructors').mockReturnValue(of({
instructors: [testInstructor1],
}));

component.loadCourseInstructors();

component.isInstructorsLoading = false;
fixture.detectChanges();

component.instructorDetailPanels[0].editPanel.isEditing = true;
component.instructorDetailPanels[0].editPanel.name = 'Example Instructor Changed';
fixture.detectChanges();

jest.spyOn(instructorService, 'updateInstructor').mockReturnValue(of({
courseId: 'exampleId',
email: '[email protected]',
joinState: JoinState.JOINED,
name: 'Example Instructor Changed',
}));

const button: any = fixture.debugElement.nativeElement.querySelector('#btn-save-instructor-1');
button.click();

expect(component.instructorDetailPanels[0].editPanel.isEditing).toBeFalsy();
expect(component.instructorDetailPanels[0].editPanel.name).toBe('Example Instructor Changed');
});

it('should load correct instructors details for given API output', () => {
jest.spyOn(instructorService, 'loadInstructors').mockReturnValue(of({
instructors: [testInstructor1, testInstructor2],
Expand Down

0 comments on commit 38341d6

Please sign in to comment.