From df8f4043a8d5a4a5c97e571570cc7dd190fb6797 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 1 Apr 2025 16:39:26 +0000 Subject: [PATCH 1/2] style: fix linting issues met ESLint --- frontend/src/controllers/students.ts | 26 +++++++++++++------------- frontend/src/controllers/teachers.ts | 18 +++++++++--------- frontend/src/queries/students.ts | 26 +++++++++++++------------- frontend/src/queries/teachers.ts | 18 +++++++++--------- frontend/src/queries/themes.ts | 4 ++-- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index 425bc018..3be72501 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -5,55 +5,55 @@ export class StudentController extends BaseController { super("student"); } - getAll(full = true) { + async getAll(full = true) { return this.get<{ students: any[] }>("/", { full }); } - getByUsername(username: string) { + async getByUsername(username: string) { return this.get<{ student: any }>(`/${username}`); } - createStudent(data: any) { + async createStudent(data: any) { return this.post("/", data); } - deleteStudent(username: string) { + async deleteStudent(username: string) { return this.delete(`/${username}`); } - getClasses(username: string, full = true) { + async getClasses(username: string, full = true) { return this.get<{ classes: any[] }>(`/${username}/classes`, { full }); } - getAssignments(username: string, full = true) { + async getAssignments(username: string, full = true) { return this.get<{ assignments: any[] }>(`/${username}/assignments`, { full }); } - getGroups(username: string, full = true) { + async getGroups(username: string, full = true) { return this.get<{ groups: any[] }>(`/${username}/groups`, { full }); } - getSubmissions(username: string) { + async getSubmissions(username: string) { return this.get<{ submissions: any[] }>(`/${username}/submissions`); } - getQuestions(username: string, full = true) { + async getQuestions(username: string, full = true) { return this.get<{ questions: any[] }>(`/${username}/questions`, { full }); } - getJoinRequests(username: string) { + async getJoinRequests(username: string) { return this.get<{ requests: any[] }>(`/${username}/joinRequests`); } - getJoinRequest(username: string, classId: string) { + async getJoinRequest(username: string, classId: string) { return this.get<{ request: any[] }>(`/${username}/joinRequests/${classId}`); } - createJoinRequest(username: string, classId: string) { + async createJoinRequest(username: string, classId: string) { return this.post(`/${username}/joinRequests}`, classId); } - deleteJoinRequest(username: string, classId: string) { + async deleteJoinRequest(username: string, classId: string) { return this.delete(`/${username}/joinRequests/${classId}`); } } diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index cdbacae7..1a496ad8 100644 --- a/frontend/src/controllers/teachers.ts +++ b/frontend/src/controllers/teachers.ts @@ -5,39 +5,39 @@ export class TeacherController extends BaseController { super("teacher"); } - getAll(full = false) { + async getAll(full = false) { return this.get<{ teachers: any[] }>("/", { full }); } - getByUsername(username: string) { + async getByUsername(username: string) { return this.get(`/${username}`); } - createTeacher(data: any) { + async createTeacher(data: any) { return this.post("/", data); } - deleteTeacher(username: string) { + async deleteTeacher(username: string) { return this.delete(`/${username}`); } - getClasses(username: string, full = false) { + async getClasses(username: string, full = false) { return this.get(`/${username}/classes`, { full }); } - getStudents(username: string, full = false) { + async getStudents(username: string, full = false) { return this.get<{ students: any[] }>(`/${username}/students`, { full }); } - getQuestions(username: string, full = false) { + async getQuestions(username: string, full = false) { return this.get<{ questions: any[] }>(`/${username}/questions`, { full }); } - getStudentJoinRequests(username: string, classId: string) { + async getStudentJoinRequests(username: string, classId: string) { return this.get<{ joinRequests: any[] }>(`/${username}/joinRequests/${classId}`); } - updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean) { + async updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean) { return this.put(`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`, accepted); } diff --git a/frontend/src/queries/students.ts b/frontend/src/queries/students.ts index d1f06fa6..810c5529 100644 --- a/frontend/src/queries/students.ts +++ b/frontend/src/queries/students.ts @@ -18,14 +18,14 @@ const STUDENT_JOIN_REQUESTS_QUERY_KEY = (username: string) => ["student-join-req export function useStudentsQuery(full: MaybeRefOrGetter = true) { return useQuery({ queryKey: computed(() => STUDENTS_QUERY_KEY(toValue(full))), - queryFn: () => studentController.getAll(toValue(full)), + queryFn: async () => studentController.getAll(toValue(full)), }); } export function useStudentQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getByUsername(toValue(username)!), + queryFn: async () => studentController.getByUsername(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -36,7 +36,7 @@ export function useStudentClassesQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_CLASSES_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getClasses(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getClasses(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -47,7 +47,7 @@ export function useStudentAssignmentsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_ASSIGNMENTS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getAssignments(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getAssignments(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -58,7 +58,7 @@ export function useStudentGroupsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_GROUPS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getGroups(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getGroups(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -66,7 +66,7 @@ export function useStudentGroupsQuery( export function useStudentSubmissionsQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_SUBMISSIONS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getSubmissions(toValue(username)!), + queryFn: async () => studentController.getSubmissions(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -77,7 +77,7 @@ export function useStudentQuestionsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_QUESTIONS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getQuestions(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getQuestions(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -86,7 +86,7 @@ export function useCreateStudentMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (data: any) => studentController.createStudent(data), + mutationFn: async (data: any) => studentController.createStudent(data), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["students"] }); }, @@ -103,7 +103,7 @@ export function useDeleteStudentMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (username: string) => studentController.deleteStudent(username), + mutationFn: async (username: string) => studentController.deleteStudent(username), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["students"] }); }, @@ -116,7 +116,7 @@ export function useDeleteStudentMutation() { export function useStudentJoinRequestsQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_JOIN_REQUESTS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getJoinRequests(toValue(username)!), + queryFn: async () => studentController.getJoinRequests(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -127,7 +127,7 @@ export function useStudentJoinRequestQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_JOIN_REQUESTS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getJoinRequest(toValue(username)!, toValue(classId)!), + queryFn: async () => studentController.getJoinRequest(toValue(username)!, toValue(classId)!), enabled: () => Boolean(toValue(username)), }); } @@ -139,7 +139,7 @@ export function useCreateJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ username, classId }: { username: string; classId: string }) => + mutationFn: async ({ username, classId }: { username: string; classId: string }) => studentController.createJoinRequest(username, classId), onSuccess: (_, { username }) => { await queryClient.invalidateQueries({ queryKey: STUDENT_JOIN_REQUESTS_QUERY_KEY(username) }); @@ -157,7 +157,7 @@ export function useDeleteJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ username, classId }: { username: string; classId: string }) => + mutationFn: async ({ username, classId }: { username: string; classId: string }) => studentController.deleteJoinRequest(username, classId), onSuccess: (_, { username }) => { await queryClient.invalidateQueries({ queryKey: STUDENT_JOIN_REQUESTS_QUERY_KEY(username) }); diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index f8ba0f6a..3daf9e1f 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -16,14 +16,14 @@ const JOIN_REQUESTS_QUERY_KEY = (username: string, classId: string) => ["join-re export function useTeachersQuery(full: MaybeRefOrGetter = false) { return useQuery({ queryKey: computed(() => TEACHERS_QUERY_KEY(toValue(full))), - queryFn: () => teacherController.getAll(toValue(full)), + queryFn: async () => teacherController.getAll(toValue(full)), }); } export function useTeacherQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => TEACHER_QUERY_KEY(toValue(username)!)), - queryFn: () => teacherController.getByUsername(toValue(username)!), + queryFn: async () => teacherController.getByUsername(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -34,7 +34,7 @@ export function useTeacherClassesQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_CLASSES_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getClasses(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getClasses(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -45,7 +45,7 @@ export function useTeacherStudentsQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_STUDENTS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getStudents(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getStudents(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -56,7 +56,7 @@ export function useTeacherQuestionsQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_QUESTIONS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getQuestions(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getQuestions(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -67,7 +67,7 @@ export function useTeacherJoinRequestsQuery( ) { return useQuery({ queryKey: computed(() => JOIN_REQUESTS_QUERY_KEY(toValue(username)!, toValue(classId)!)), - queryFn: () => teacherController.getStudentJoinRequests(toValue(username)!, toValue(classId)!), + queryFn: async () => teacherController.getStudentJoinRequests(toValue(username)!, toValue(classId)!), enabled: () => Boolean(toValue(username)) && Boolean(toValue(classId)), }); } @@ -76,7 +76,7 @@ export function useCreateTeacherMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (data: any) => teacherController.createTeacher(data), + mutationFn: async (data: any) => teacherController.createTeacher(data), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); }, @@ -90,7 +90,7 @@ export function useDeleteTeacherMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (username: string) => teacherController.deleteTeacher(username), + mutationFn: async (username: string) => teacherController.deleteTeacher(username), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); }, @@ -104,7 +104,7 @@ export function useUpdateJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ + mutationFn: async ({ teacherUsername, classId, studentUsername, diff --git a/frontend/src/queries/themes.ts b/frontend/src/queries/themes.ts index 17264a96..65bf9237 100644 --- a/frontend/src/queries/themes.ts +++ b/frontend/src/queries/themes.ts @@ -7,7 +7,7 @@ const themeController = new ThemeController(); export function useThemeQuery(language: MaybeRefOrGetter) { return useQuery({ queryKey: ["themes", language], - queryFn: () => { + queryFn: async () => { const lang = toValue(language); return themeController.getAll(lang); }, @@ -18,7 +18,7 @@ export function useThemeQuery(language: MaybeRefOrGetter) { export function useThemeHruidsQuery(themeKey: MaybeRefOrGetter) { return useQuery({ queryKey: ["theme-hruids", themeKey], - queryFn: () => themeController.getHruidsByKey(toValue(themeKey)!), + queryFn: async () => themeController.getHruidsByKey(toValue(themeKey)!), enabled: Boolean(themeKey), }); } From b9681926f80d666b4f7c4e7352c085c3320cd9fa Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 1 Apr 2025 16:39:31 +0000 Subject: [PATCH 2/2] style: fix linting issues met Prettier --- backend/src/controllers/students.ts | 3 ++- backend/src/interfaces/answer.ts | 2 +- backend/src/routes/student-join-requests.ts | 2 +- backend/src/services/questions.ts | 2 +- backend/src/services/students.ts | 13 ++++------- backend/src/services/teachers.ts | 7 +----- backend/tests/controllers/students.test.ts | 23 ++++++++----------- backend/tests/controllers/teachers.test.ts | 14 ++++------- .../test_assets/users/students.testdata.ts | 2 +- frontend/src/controllers/teachers.ts | 7 +++++- 10 files changed, 31 insertions(+), 44 deletions(-) diff --git a/backend/src/controllers/students.ts b/backend/src/controllers/students.ts index 7f00d640..4bc4394e 100644 --- a/backend/src/controllers/students.ts +++ b/backend/src/controllers/students.ts @@ -4,7 +4,8 @@ import { createStudent, deleteClassJoinRequest, deleteStudent, - getAllStudents, getJoinRequestByStudentClass, + getAllStudents, + getJoinRequestByStudentClass, getJoinRequestsByStudent, getStudent, getStudentAssignments, diff --git a/backend/src/interfaces/answer.ts b/backend/src/interfaces/answer.ts index 1162a1d3..5d395958 100644 --- a/backend/src/interfaces/answer.ts +++ b/backend/src/interfaces/answer.ts @@ -1,5 +1,5 @@ import { mapToUserDTO, UserDTO } from './user.js'; -import {mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId} from './question.js'; +import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from './question.js'; import { Answer } from '../entities/questions/answer.entity.js'; export interface AnswerDTO { diff --git a/backend/src/routes/student-join-requests.ts b/backend/src/routes/student-join-requests.ts index 6204e74d..daf79f09 100644 --- a/backend/src/routes/student-join-requests.ts +++ b/backend/src/routes/student-join-requests.ts @@ -3,7 +3,7 @@ import { createStudentRequestHandler, deleteClassJoinRequestHandler, getStudentRequestHandler, - getStudentRequestsHandler + getStudentRequestsHandler, } from '../controllers/students.js'; const router = express.Router({ mergeParams: true }); diff --git a/backend/src/services/questions.ts b/backend/src/services/questions.ts index 589ae115..44f26a1d 100644 --- a/backend/src/services/questions.ts +++ b/backend/src/services/questions.ts @@ -1,5 +1,5 @@ import { getAnswerRepository, getQuestionRepository } from '../data/repositories.js'; -import {mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId} from '../interfaces/question.js'; +import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; import { Question } from '../entities/questions/question.entity.js'; import { Answer } from '../entities/questions/answer.entity.js'; import { AnswerDTO, AnswerId, mapToAnswerDTO, mapToAnswerDTOId } from '../interfaces/answer.js'; diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index dde5bf0d..3f528dbc 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -12,13 +12,8 @@ import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; import { getAllAssignments } from './assignments.js'; -import { - mapToQuestionDTO, - mapToQuestionDTOId, - QuestionDTO, - QuestionId -} from '../interfaces/question.js'; -import {mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO} from '../interfaces/student-request.js'; +import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; +import { mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; import { Student } from '../entities/users/student.entity.js'; import { NotFoundException } from '../exceptions/not-found-exception.js'; import { fetchClass } from './classes.js'; @@ -148,14 +143,14 @@ export async function getJoinRequestsByStudent(username: string): Promise{ +export async function getJoinRequestByStudentClass(username: string, classId: string): Promise { const requestRepo = getClassJoinRequestRepository(); const student = await fetchStudent(username); const cls = await fetchClass(classId); const request = await requestRepo.findByStudentAndClass(student, cls); - if (!request){ + if (!request) { throw new NotFoundException('Join request not found'); } diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index ddd81a02..98ac0a83 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -6,12 +6,7 @@ import { getTeacherRepository, } from '../data/repositories.js'; import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; -import { - mapToQuestionDTO, - mapToQuestionDTOId, - QuestionDTO, - QuestionId -} from '../interfaces/question.js'; +import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; import { Teacher } from '../entities/users/teacher.entity.js'; import { fetchStudent } from './students.js'; diff --git a/backend/tests/controllers/students.test.ts b/backend/tests/controllers/students.test.ts index cf72f28c..607449aa 100644 --- a/backend/tests/controllers/students.test.ts +++ b/backend/tests/controllers/students.test.ts @@ -12,7 +12,8 @@ import { getStudentQuestionsHandler, createStudentRequestHandler, getStudentRequestsHandler, - deleteClassJoinRequestHandler, getStudentRequestHandler, + deleteClassJoinRequestHandler, + getStudentRequestHandler, } from '../../src/controllers/students.js'; import { TEST_STUDENTS } from '../test_assets/users/students.testdata.js'; import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; @@ -49,15 +50,13 @@ describe('Student controllers', () => { it('Student not found', async () => { req = { params: { username: 'doesnotexist' } }; - await expect(async () => getStudentHandler(req as Request, res as Response)) - .rejects.toThrow(NotFoundException); + await expect(async () => getStudentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); }); it('No username', async () => { req = { params: {} }; - await expect(async () => getStudentHandler(req as Request, res as Response)) - .rejects.toThrowError(BadRequestException); + await expect(async () => getStudentHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); }); it('Create and delete student', async () => { @@ -68,7 +67,7 @@ describe('Student controllers', () => { lastName: 'Student', } as StudentDTO; req = { - body: student + body: student, }; await createStudentHandler(req as Request, res as Response); @@ -91,15 +90,13 @@ describe('Student controllers', () => { }, }; - await expect(async () => createStudentHandler(req as Request, res as Response)) - .rejects.toThrowError(EntityAlreadyExistsException); + await expect(async () => createStudentHandler(req as Request, res as Response)).rejects.toThrowError(EntityAlreadyExistsException); }); it('Create student no body', async () => { req = { body: {} }; - await expect(async () => createStudentHandler(req as Request, res as Response)) - .rejects.toThrowError(BadRequestException); + await expect(async () => createStudentHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); }); it('Student list', async () => { @@ -218,8 +215,7 @@ describe('Student controllers', () => { body: { classId: 'id02' }, }; - await expect(async () => createStudentRequestHandler(req as Request, res as Response)) - .rejects.toThrow(ConflictException); + await expect(async () => createStudentRequestHandler(req as Request, res as Response)).rejects.toThrow(ConflictException); }); it('Delete join request', async () => { @@ -231,7 +227,6 @@ describe('Student controllers', () => { expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ request: expect.anything() })); - await expect(async () => deleteClassJoinRequestHandler(req as Request, res as Response)) - .rejects.toThrow(NotFoundException); + await expect(async () => deleteClassJoinRequestHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); }); }); diff --git a/backend/tests/controllers/teachers.test.ts b/backend/tests/controllers/teachers.test.ts index a0b5f648..d48481c2 100644 --- a/backend/tests/controllers/teachers.test.ts +++ b/backend/tests/controllers/teachers.test.ts @@ -45,15 +45,13 @@ describe('Teacher controllers', () => { it('Teacher not found', async () => { req = { params: { username: 'doesnotexist' } }; - await expect(async () => getTeacherHandler(req as Request, res as Response)) - .rejects.toThrow(NotFoundException); + await expect(async () => getTeacherHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); }); it('No username', async () => { req = { params: {} }; - await expect(async () => getTeacherHandler(req as Request, res as Response)) - .rejects.toThrowError(BadRequestException); + await expect(async () => getTeacherHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); }); it('Create and delete teacher', async () => { @@ -62,7 +60,7 @@ describe('Teacher controllers', () => { username: 'coolteacher', firstName: 'New', lastName: 'Teacher', - } + }; req = { body: teacher, }; @@ -87,15 +85,13 @@ describe('Teacher controllers', () => { }, }; - await expect(async () => createTeacherHandler(req as Request, res as Response)) - .rejects.toThrowError(EntityAlreadyExistsException); + await expect(async () => createTeacherHandler(req as Request, res as Response)).rejects.toThrowError(EntityAlreadyExistsException); }); it('Create teacher no body', async () => { req = { body: {} }; - await expect(async () => createTeacherHandler(req as Request, res as Response)) - .rejects.toThrowError(BadRequestException); + await expect(async () => createTeacherHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); }); it('Teacher list', async () => { diff --git a/backend/tests/test_assets/users/students.testdata.ts b/backend/tests/test_assets/users/students.testdata.ts index ba34c728..5cd75787 100644 --- a/backend/tests/test_assets/users/students.testdata.ts +++ b/backend/tests/test_assets/users/students.testdata.ts @@ -1,4 +1,4 @@ -import { EntityManager} from '@mikro-orm/core'; +import { EntityManager } from '@mikro-orm/core'; import { Student } from '../../../src/entities/users/student.entity'; // 🔓 Ruwe testdata array — herbruikbaar in assertions diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index 1a496ad8..229eced5 100644 --- a/frontend/src/controllers/teachers.ts +++ b/frontend/src/controllers/teachers.ts @@ -37,7 +37,12 @@ export class TeacherController extends BaseController { return this.get<{ joinRequests: any[] }>(`/${username}/joinRequests/${classId}`); } - async updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean) { + async updateStudentJoinRequest( + teacherUsername: string, + classId: string, + studentUsername: string, + accepted: boolean, + ) { return this.put(`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`, accepted); }