Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#10920] Add testing for sortCoursesBy method in instructor home page. #12440

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ const testCourse2: Course = {
timeZone: 'Asia/Singapore',
};

const testCourse3: Course = {
courseId: 'CS0234',
courseName: 'Data Structures',
institute: 'Test Institute',
creationTimestamp: 1676841600000, // Sunday, 21 May 2023 08:00:00 GMT+08:00
deletionTimestamp: 0,
timeZone: 'Asia/Singapore',
};

const testFeedbackSession1: FeedbackSession = {
feedbackSessionName: 'First Session',
courseId: 'CS1231',
Expand Down Expand Up @@ -271,6 +280,27 @@ describe('InstructorHomePageComponent', () => {
.feedbackSession.feedbackSessionName).toEqual('First Session');
});

it('should sort courseTabModels by courseId in ascending order', () => {
const activeCourses: CourseTabModel[] = activeCourseTabModels;
activeCourses.push({
course: testCourse3,
instructorPrivilege: testInstructorPrivilege,
sessionsTableRowModels: [],
sessionsTableRowModelsSortBy: SortBy.NONE,
sessionsTableRowModelsSortOrder: SortOrder.ASC,

hasPopulated: false,
isAjaxSuccess: true,
isTabExpanded: true,
hasLoadingFailed: false,
});
YvetteJian marked this conversation as resolved.
Show resolved Hide resolved

component.courseTabModels = activeCourses;
component.sortCoursesBy(SortBy.COURSE_ID);
YvetteJian marked this conversation as resolved.
Show resolved Hide resolved
expect(component.courseTabModels[0].course.courseId).toEqual('CS0234');
expect(component.courseTabModels[0].course.courseName).toEqual('Data Structures');
});

it('should snap with default fields', () => {
expect(fixture).toMatchSnapshot();
});
Expand Down
Loading