diff --git a/src/screens/Admin/Instructors/InstructorList.jsx b/src/screens/Admin/Instructors/InstructorList.jsx index b11f7a33e..12560f918 100644 --- a/src/screens/Admin/Instructors/InstructorList.jsx +++ b/src/screens/Admin/Instructors/InstructorList.jsx @@ -29,6 +29,14 @@ export default function InstructorList({ instructors, loading, currUni, onInacti setSearchText(''); }; + const formatInstructorName = (instructor) => { + if(instructor.firstName || instructor.lastName) { + return `${instructor.firstName || ''} ${instructor.lastName || ''}`.trim(); + } else { + return "Unknown"; + } + } + return ( <>
@@ -48,7 +56,7 @@ export default function InstructorList({ instructors, loading, currUni, onInacti
{result.map((inst) => ( onInactive(inst.email)} loading={loading} diff --git a/src/screens/Admin/Instructors/InstructorList.test.js b/src/screens/Admin/Instructors/InstructorList.test.js index f25cddb8e..03b8785e2 100644 --- a/src/screens/Admin/Instructors/InstructorList.test.js +++ b/src/screens/Admin/Instructors/InstructorList.test.js @@ -34,7 +34,7 @@ describe('Instructor List', () => { expect(screen.getByText("Harsh Deep")).toBeVisible(); expect(screen.getByText("Alan")).toBeVisible(); - expect(screen.getByText("Unknown Turing")).toBeVisible(); + expect(screen.getByText("Turing")).toBeVisible(); expect(screen.getByText("Email: harsh@example.com")).toBeVisible(); expect(screen.getByText("Email: alan@example.com")).toBeVisible(); @@ -61,7 +61,7 @@ describe('Instructor List', () => { await userEvent.click(searchButton); expect(numberOfInstructors()).toBe(1); - expect(screen.getByText("Unknown Turing")).toBeVisible(); + expect(screen.getByText("Turing")).toBeVisible(); // Email await userEvent.clear(searchField);