fix: merge + lint fixes

This commit is contained in:
Gabriellvl 2025-04-01 18:38:36 +02:00
parent 7f189188e8
commit b556516359
12 changed files with 58 additions and 62 deletions

View file

@ -49,14 +49,14 @@ describe('Student controllers', () => {
it('Student not found', async () => {
req = { params: { username: 'doesnotexist' } };
await expect(() => getStudentHandler(req as Request, res as Response))
await expect(async () => getStudentHandler(req as Request, res as Response))
.rejects.toThrow(NotFoundException);
});
it('No username', async () => {
req = { params: {} };
await expect(() => getStudentHandler(req as Request, res as Response))
await expect(async () => getStudentHandler(req as Request, res as Response))
.rejects.toThrowError(BadRequestException);
});
@ -75,8 +75,6 @@ describe('Student controllers', () => {
expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ student: expect.objectContaining(student) }));
console.log(jsonMock)
req = { params: { username: 'coolstudent' } };
await deleteStudentHandler(req as Request, res as Response);
@ -93,14 +91,14 @@ describe('Student controllers', () => {
},
};
await expect(() => createStudentHandler(req as Request, res as Response))
await expect(async () => createStudentHandler(req as Request, res as Response))
.rejects.toThrowError(EntityAlreadyExistsException);
});
it('Create student no body', async () => {
req = { body: {} };
await expect(() => createStudentHandler(req as Request, res as Response))
await expect(async () => createStudentHandler(req as Request, res as Response))
.rejects.toThrowError(BadRequestException);
});
@ -168,7 +166,7 @@ describe('Student controllers', () => {
it('Deleting non-existent student', async () => {
req = { params: { username: 'doesnotexist' } };
await expect(() => deleteStudentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException);
await expect(async () => deleteStudentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException);
});
it('Get join requests by student', async () => {
@ -220,7 +218,7 @@ describe('Student controllers', () => {
body: { classId: 'id02' },
};
await expect(() => createStudentRequestHandler(req as Request, res as Response))
await expect(async () => createStudentRequestHandler(req as Request, res as Response))
.rejects.toThrow(ConflictException);
});
@ -233,7 +231,7 @@ describe('Student controllers', () => {
expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ request: expect.anything() }));
await expect(() => deleteClassJoinRequestHandler(req as Request, res as Response))
await expect(async () => deleteClassJoinRequestHandler(req as Request, res as Response))
.rejects.toThrow(NotFoundException);
});
});

View file

@ -9,7 +9,6 @@ import {
getStudentJoinRequestHandler,
getTeacherClassHandler,
getTeacherHandler,
getTeacherQuestionHandler,
getTeacherStudentHandler,
updateStudentJoinRequestHandler,
} from '../../src/controllers/teachers.js';
@ -46,14 +45,14 @@ describe('Teacher controllers', () => {
it('Teacher not found', async () => {
req = { params: { username: 'doesnotexist' } };
await expect(() => getTeacherHandler(req as Request, res as Response))
await expect(async () => getTeacherHandler(req as Request, res as Response))
.rejects.toThrow(NotFoundException);
});
it('No username', async () => {
req = { params: {} };
await expect(() => getTeacherHandler(req as Request, res as Response))
await expect(async () => getTeacherHandler(req as Request, res as Response))
.rejects.toThrowError(BadRequestException);
});
@ -88,14 +87,14 @@ describe('Teacher controllers', () => {
},
};
await expect(() => createTeacherHandler(req as Request, res as Response))
await expect(async () => createTeacherHandler(req as Request, res as Response))
.rejects.toThrowError(EntityAlreadyExistsException);
});
it('Create teacher no body', async () => {
req = { body: {} };
await expect(() => createTeacherHandler(req as Request, res as Response))
await expect(async () => createTeacherHandler(req as Request, res as Response))
.rejects.toThrowError(BadRequestException);
});
@ -117,7 +116,7 @@ describe('Teacher controllers', () => {
it('Deleting non-existent student', async () => {
req = { params: { username: 'doesnotexist' } };
await expect(() => deleteTeacherHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException);
await expect(async () => deleteTeacherHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException);
});
it('Get teacher classes', async () => {
@ -193,9 +192,9 @@ describe('Teacher controllers', () => {
body: { accepted: 'true' },
};
const teacher = await updateStudentJoinRequestHandler(req as Request, res as Response);
await updateStudentJoinRequestHandler(req as Request, res as Response);
expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ teacher: expect.objectContaining(teacher) }));
expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ request: expect.anything() }));
req = {
params: { username: 'PinkFloyd' },
@ -204,6 +203,6 @@ describe('Teacher controllers', () => {
await getStudentRequestsHandler(req as Request, res as Response);
const status: boolean = jsonMock.mock.lastCall?.[0].requests[0].status;
expect(status).toBeTruthy;
expect(status).toBeTruthy();
});
});