From e773b2d611f56c69e255d9ca3c77ab0479caf689 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 10 May 2025 18:07:50 +0000 Subject: [PATCH] style: fix linting issues met Prettier --- backend/tests/controllers/assignments.test.ts | 50 ++++++++++--------- backend/tests/controllers/classes.test.ts | 22 +++++--- backend/tests/controllers/groups.test.ts | 19 +++---- backend/tests/controllers/submissions.test.ts | 45 +++++++++-------- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts index 81138ce3..d21e9f3f 100644 --- a/backend/tests/controllers/assignments.test.ts +++ b/backend/tests/controllers/assignments.test.ts @@ -2,13 +2,16 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; import { Request, Response } from 'express'; import { getAssignmentHandler, getAllAssignmentsHandler, getAssignmentsSubmissionsHandler } from '../../src/controllers/assignments.js'; -import { NotFoundException } from "../../src/exceptions/not-found-exception"; -import { getClass01 } from "../test_assets/classes/classes.testdata"; -import { getAssignment01 } from "../test_assets/assignments/assignments.testdata"; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; +import { getAssignment01 } from '../test_assets/assignments/assignments.testdata'; -function createRequestObject(classid: string, assignmentid: string): { +function createRequestObject( + classid: string, + assignmentid: string +): { query: {}; - params: { classid: string; id: string } + params: { classid: string; id: string }; } { return { params: { @@ -30,7 +33,7 @@ describe('Assignment controllers', () => { await setupTestApp(); }); - beforeEach(async () => { + beforeEach(async () => { jsonMock = vi.fn(); statusMock = vi.fn().mockReturnThis(); @@ -46,27 +49,26 @@ describe('Assignment controllers', () => { await expect(async () => getAssignmentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); }); - it('should return an assignment', async () => { - const assignment = getAssignment01(); - req = createRequestObject(assignment.within.classId as string, (assignment.id ?? 1).toString()); - - await getAssignmentHandler(req as Request, res as Response); - expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignment: expect.anything() })); - - }); - - it('should return a list of assignments', async () => { - req = createRequestObject(getClass01().classId as string, 'irrelevant'); - - await getAllAssignmentsHandler(req as Request, res as Response); - expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignments: expect.anything() })); }); - - it('should return a list of submissions for an assignment', async () => { + it('should return an assignment', async () => { const assignment = getAssignment01(); req = createRequestObject(assignment.within.classId as string, (assignment.id ?? 1).toString()); + await getAssignmentHandler(req as Request, res as Response); + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignment: expect.anything() })); + }); + + it('should return a list of assignments', async () => { + req = createRequestObject(getClass01().classId as string, 'irrelevant'); + + await getAllAssignmentsHandler(req as Request, res as Response); + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignments: expect.anything() })); + }); + + it('should return a list of submissions for an assignment', async () => { + const assignment = getAssignment01(); + req = createRequestObject(assignment.within.classId as string, (assignment.id ?? 1).toString()); await getAssignmentsSubmissionsHandler(req as Request, res as Response); expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ submissions: expect.anything() })); - }) -}) + }); +}); diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts index a8c4f40c..d9614a3b 100644 --- a/backend/tests/controllers/classes.test.ts +++ b/backend/tests/controllers/classes.test.ts @@ -1,10 +1,17 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; -import { createClassHandler, deleteClassHandler, getAllClassesHandler, getClassHandler, getClassStudentsHandler, getTeacherInvitationsHandler } from '../../src/controllers/classes.js'; +import { + createClassHandler, + deleteClassHandler, + getAllClassesHandler, + getClassHandler, + getClassStudentsHandler, + getTeacherInvitationsHandler, +} from '../../src/controllers/classes.js'; import { Request, Response } from 'express'; -import {NotFoundException} from "../../src/exceptions/not-found-exception"; -import {BadRequestException} from "../../src/exceptions/bad-request-exception"; -import {getClass01} from "../test_assets/classes/classes.testdata"; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { BadRequestException } from '../../src/exceptions/bad-request-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; describe('Class controllers', () => { let req: Partial; let res: Partial; @@ -49,8 +56,8 @@ describe('Class controllers', () => { it('Error class not found', async () => { req = { - params: { id: 'doesnotexist'}, - } + params: { id: 'doesnotexist' }, + }; await expect(async () => getClassHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); }); @@ -112,6 +119,5 @@ describe('Class controllers', () => { await getAllClassesHandler(req as Request, res as Response); expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ classes: expect.anything() })); - }) - + }); }); diff --git a/backend/tests/controllers/groups.test.ts b/backend/tests/controllers/groups.test.ts index 3888fef5..aed99d3d 100644 --- a/backend/tests/controllers/groups.test.ts +++ b/backend/tests/controllers/groups.test.ts @@ -6,12 +6,12 @@ import { deleteGroupHandler, getAllGroupsHandler, getGroupHandler, - getGroupSubmissionsHandler + getGroupSubmissionsHandler, } from '../../src/controllers/groups.js'; -import { NotFoundException } from "../../src/exceptions/not-found-exception"; -import { getClass01 } from "../test_assets/classes/classes.testdata"; -import { getAssignment01, getAssignment02 } from "../test_assets/assignments/assignments.testdata"; -import { getTestGroup01 } from "../test_assets/assignments/groups.testdata"; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; +import { getAssignment01, getAssignment02 } from '../test_assets/assignments/assignments.testdata'; +import { getTestGroup01 } from '../test_assets/assignments/groups.testdata'; function createRequestObject(classid: string, assignmentid: string, groupNumber: string) { return { @@ -35,7 +35,7 @@ describe('Group controllers', () => { await setupTestApp(); }); - beforeEach(async () => { + beforeEach(async () => { jsonMock = vi.fn(); statusMock = vi.fn().mockReturnThis(); @@ -56,7 +56,6 @@ describe('Group controllers', () => { }; await expect(async () => getGroupHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); - }); it('should return 404 not found on a non-existing assignment', async () => { @@ -95,16 +94,12 @@ describe('Group controllers', () => { expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ group: expect.anything() })); }); - it('Create and delete', async () => { const assignment = getAssignment02(); const classId = assignment.within.classId as string; req = createRequestObject(classId, (assignment.id ?? 1).toString(), '1'); req.body = { - members: [ - 'Noordkaap', - 'DireStraits', - ] + members: ['Noordkaap', 'DireStraits'], }; await createGroupHandler(req as Request, res as Response); diff --git a/backend/tests/controllers/submissions.test.ts b/backend/tests/controllers/submissions.test.ts index c246ab38..942b51f8 100644 --- a/backend/tests/controllers/submissions.test.ts +++ b/backend/tests/controllers/submissions.test.ts @@ -2,24 +2,26 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; import { getSubmissionHandler, getAllSubmissionsHandler } from '../../src/controllers/submissions.js'; import { Request, Response } from 'express'; -import { NotFoundException } from "../../src/exceptions/not-found-exception"; -import { getClass02 } from "../test_assets/classes/classes.testdata"; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass02 } from '../test_assets/classes/classes.testdata'; - -function createRequestObject(hruid: string, submissionNumber: string): { +function createRequestObject( + hruid: string, + submissionNumber: string +): { query: { language: string; version: string }; - params: { hruid: string; id: string } + params: { hruid: string; id: string }; } { - return { - params: { - hruid: hruid, - id: submissionNumber, - }, - query: { - language: 'en', - version: '1', - }, - } + return { + params: { + hruid: hruid, + id: submissionNumber, + }, + query: { + language: 'en', + version: '1', + }, + }; } describe('Submission controllers', () => { @@ -33,7 +35,7 @@ describe('Submission controllers', () => { await setupTestApp(); }); - beforeEach(async () => { + beforeEach(async () => { jsonMock = vi.fn(); statusMock = vi.fn().mockReturnThis(); @@ -44,17 +46,16 @@ describe('Submission controllers', () => { }); it('error submission is not found', async () => { - req = createRequestObject('id01', '1000000'); + req = createRequestObject('id01', '1000000'); await expect(async () => getSubmissionHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); - }); + }); - it('should return a list of submissions for a learning object', async () => { - req = createRequestObject(getClass02().classId as string, 'irrelevant'); + it('should return a list of submissions for a learning object', async () => { + req = createRequestObject(getClass02().classId as string, 'irrelevant'); - await getAllSubmissionsHandler(req as Request, res as Response); + await getAllSubmissionsHandler(req as Request, res as Response); expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ submissions: expect.anything() })); }); }); -