style: fix linting issues met Prettier
This commit is contained in:
		
							parent
							
								
									4a6b6ee061
								
							
						
					
					
						commit
						437c2ba2fe
					
				
					 9 changed files with 170 additions and 170 deletions
				
			
		|  | @ -1,65 +1,65 @@ | ||||||
| import { describe, it, expect, beforeEach } from 'vitest'; | import { describe, it, expect, beforeEach } from "vitest"; | ||||||
| import { AssignmentController } from '../../src/controllers/assignments'; | import { AssignmentController } from "../../src/controllers/assignments"; | ||||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | import { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; | ||||||
| 
 | 
 | ||||||
| describe('AssignmentController Tests', () => { | describe("AssignmentController Tests", () => { | ||||||
|   let controller: AssignmentController; |     let controller: AssignmentController; | ||||||
| 
 | 
 | ||||||
|   beforeEach(() => { |     beforeEach(() => { | ||||||
|     controller = new AssignmentController('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); // Example class ID
 |         controller = new AssignmentController("8764b861-90a6-42e5-9732-c0d9eb2f55f9"); // Example class ID
 | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should fetch all assignments', async () => { |     it("should fetch all assignments", async () => { | ||||||
|     const result = await controller.getAll(true); |         const result = await controller.getAll(true); | ||||||
|     expect(result).toHaveProperty('assignments'); |         expect(result).toHaveProperty("assignments"); | ||||||
|     expect(Array.isArray(result.assignments)).toBe(true); |         expect(Array.isArray(result.assignments)).toBe(true); | ||||||
|     expect(result.assignments.length).toBeGreaterThan(0); |         expect(result.assignments.length).toBeGreaterThan(0); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should fetch an assignment by number', async () => { |     it("should fetch an assignment by number", async () => { | ||||||
|     const assignmentNumber = 21000; // Example assignment ID
 |         const assignmentNumber = 21000; // Example assignment ID
 | ||||||
|     const result = await controller.getByNumber(assignmentNumber); |         const result = await controller.getByNumber(assignmentNumber); | ||||||
|     expect(result).toHaveProperty('assignment'); |         expect(result).toHaveProperty("assignment"); | ||||||
|     expect(result.assignment).toHaveProperty('id', assignmentNumber); |         expect(result.assignment).toHaveProperty("id", assignmentNumber); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should update an existing assignment', async () => { |     it("should update an existing assignment", async () => { | ||||||
|     const assignmentNumber = 21000; |         const assignmentNumber = 21000; | ||||||
|     const updatedData = { title: 'Updated Assignment Title' }; |         const updatedData = { title: "Updated Assignment Title" }; | ||||||
|     const result = await controller.updateAssignment(assignmentNumber, updatedData); |         const result = await controller.updateAssignment(assignmentNumber, updatedData); | ||||||
|     expect(result).toHaveProperty('assignment'); |         expect(result).toHaveProperty("assignment"); | ||||||
|     expect(result.assignment).toHaveProperty('id', assignmentNumber); |         expect(result.assignment).toHaveProperty("id", assignmentNumber); | ||||||
|     expect(result.assignment).toHaveProperty('title', updatedData.title); |         expect(result.assignment).toHaveProperty("title", updatedData.title); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should fetch submissions for an assignment', async () => { |     it("should fetch submissions for an assignment", async () => { | ||||||
|     const assignmentNumber = 21000; |         const assignmentNumber = 21000; | ||||||
|     const result = await controller.getSubmissions(assignmentNumber, true); |         const result = await controller.getSubmissions(assignmentNumber, true); | ||||||
|     expect(result).toHaveProperty('submissions'); |         expect(result).toHaveProperty("submissions"); | ||||||
|     expect(Array.isArray(result.submissions)).toBe(true); |         expect(Array.isArray(result.submissions)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should fetch questions for an assignment', async () => { |     it("should fetch questions for an assignment", async () => { | ||||||
|     const assignmentNumber = 21000; |         const assignmentNumber = 21000; | ||||||
|     const result = await controller.getQuestions(assignmentNumber, true); |         const result = await controller.getQuestions(assignmentNumber, true); | ||||||
|     expect(result).toHaveProperty('questions'); |         expect(result).toHaveProperty("questions"); | ||||||
|     expect(Array.isArray(result.questions)).toBe(true); |         expect(Array.isArray(result.questions)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should fetch groups for an assignment', async () => { |     it("should fetch groups for an assignment", async () => { | ||||||
|     const assignmentNumber = 21000; |         const assignmentNumber = 21000; | ||||||
|     const result = await controller.getGroups(assignmentNumber, true); |         const result = await controller.getGroups(assignmentNumber, true); | ||||||
|     expect(result).toHaveProperty('groups'); |         expect(result).toHaveProperty("groups"); | ||||||
|     expect(Array.isArray(result.groups)).toBe(true); |         expect(Array.isArray(result.groups)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should handle fetching a non-existent assignment', async () => { |     it("should handle fetching a non-existent assignment", async () => { | ||||||
|     const assignmentNumber = 99999; // Non-existent assignment ID
 |         const assignmentNumber = 99999; // Non-existent assignment ID
 | ||||||
|     await expect(controller.getByNumber(assignmentNumber)).rejects.toThrow(); |         await expect(controller.getByNumber(assignmentNumber)).rejects.toThrow(); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should handle deleting a non-existent assignment', async () => { |     it("should handle deleting a non-existent assignment", async () => { | ||||||
|     const assignmentNumber = 99999; // Non-existent assignment ID
 |         const assignmentNumber = 99999; // Non-existent assignment ID
 | ||||||
|     await expect(controller.deleteAssignment(assignmentNumber)).rejects.toThrow(); |         await expect(controller.deleteAssignment(assignmentNumber)).rejects.toThrow(); | ||||||
|   }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import { describe, expect, it } from 'vitest'; | import { describe, expect, it } from "vitest"; | ||||||
| import { ClassController } from '../../src/controllers/classes'; | import { ClassController } from "../../src/controllers/classes"; | ||||||
| 
 | 
 | ||||||
| describe('Test controller classes', () => { | describe("Test controller classes", () => { | ||||||
|     it('Get classes', async () => { |     it("Get classes", async () => { | ||||||
|         const controller = new ClassController(); |         const controller = new ClassController(); | ||||||
|         const data = await controller.getAll(true); |         const data = await controller.getAll(true); | ||||||
|         expect(data.classes).to.have.length.greaterThan(0); |         expect(data.classes).to.have.length.greaterThan(0); | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| import { describe, expect, it } from 'vitest'; | import { describe, expect, it } from "vitest"; | ||||||
| import { GroupController } from '../../src/controllers/groups'; | import { GroupController } from "../../src/controllers/groups"; | ||||||
| 
 | 
 | ||||||
| describe('Test controller groups', () => { | describe("Test controller groups", () => { | ||||||
|     it('Get groups', async () => { |     it("Get groups", async () => { | ||||||
|         const classId = '8764b861-90a6-42e5-9732-c0d9eb2f55f9'; |         const classId = "8764b861-90a6-42e5-9732-c0d9eb2f55f9"; | ||||||
|         const assignmentNumber = 21000; |         const assignmentNumber = 21000; | ||||||
| 
 | 
 | ||||||
|         const controller = new GroupController(classId, assignmentNumber); |         const controller = new GroupController(classId, assignmentNumber); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { beforeEach, describe, expect, it } from 'vitest'; | import { beforeEach, describe, expect, it } from "vitest"; | ||||||
| import { LearningPathController } from '../../src/controllers/learning-paths'; | import { LearningPathController } from "../../src/controllers/learning-paths"; | ||||||
| import { Language } from '../../src/data-objects/language'; | import { Language } from "../../src/data-objects/language"; | ||||||
| 
 | 
 | ||||||
| describe("Test controller learning paths", () => { | describe("Test controller learning paths", () => { | ||||||
|     let controller: LearningPathController; |     let controller: LearningPathController; | ||||||
|  |  | ||||||
|  | @ -1,25 +1,25 @@ | ||||||
| import { StudentController } from '../../src/controllers/students'; | import { StudentController } from "../../src/controllers/students"; | ||||||
| import { beforeEach, describe, expect, it } from 'vitest'; | import { beforeEach, describe, expect, it } from "vitest"; | ||||||
| 
 | 
 | ||||||
| describe('Test controller students', () => { | describe("Test controller students", () => { | ||||||
|     let controller: StudentController; |     let controller: StudentController; | ||||||
| 
 | 
 | ||||||
|     beforeEach(async () => { |     beforeEach(async () => { | ||||||
|         controller = new StudentController(); |         controller = new StudentController(); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it('Get students', async () => { |     it("Get students", async () => { | ||||||
|         const data = await controller.getAll(true); |         const data = await controller.getAll(true); | ||||||
|         expect(data.students).to.have.length.greaterThan(0); |         expect(data.students).to.have.length.greaterThan(0); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it('Get student by username', async () => { |     it("Get student by username", async () => { | ||||||
|         const username = 'testleerling1'; |         const username = "testleerling1"; | ||||||
|         const data = await controller.getByUsername(username); |         const data = await controller.getByUsername(username); | ||||||
|         expect(data.student.username).to.equal(username); |         expect(data.student.username).to.equal(username); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it('Get classes of student', async () => { |     it("Get classes of student", async () => { | ||||||
|         const students = await controller.getAll(true); |         const students = await controller.getAll(true); | ||||||
| 
 | 
 | ||||||
|         for (const student of students.students) { |         for (const student of students.students) { | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { describe, expect, it } from 'vitest'; | import { describe, expect, it } from "vitest"; | ||||||
| import { SubmissionController } from '../../src/controllers/submissions'; | import { SubmissionController } from "../../src/controllers/submissions"; | ||||||
| import { Language } from '../../src/data-objects/language'; | import { Language } from "../../src/data-objects/language"; | ||||||
| 
 | 
 | ||||||
| describe("Test controller submissions", () => { | describe("Test controller submissions", () => { | ||||||
|     it("Get submission by number", async () => { |     it("Get submission by number", async () => { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import { beforeEach, describe, expect, it } from 'vitest'; | import { beforeEach, describe, expect, it } from "vitest"; | ||||||
| import { TeacherController } from '../../src/controllers/teachers'; | import { TeacherController } from "../../src/controllers/teachers"; | ||||||
| 
 | 
 | ||||||
| describe("Test controller teachers", () => { | describe("Test controller teachers", () => { | ||||||
|     let controller: TeacherController; |     let controller: TeacherController; | ||||||
|  |  | ||||||
|  | @ -1,82 +1,82 @@ | ||||||
| import { describe, expect, it } from 'vitest'; | import { describe, expect, it } from "vitest"; | ||||||
| import { | import { | ||||||
|     assignmentTitleRules, |     assignmentTitleRules, | ||||||
|     classRules, |     classRules, | ||||||
|     deadlineRules, |     deadlineRules, | ||||||
|     descriptionRules, |     descriptionRules, | ||||||
|     learningPathRules, |     learningPathRules, | ||||||
| } from '../../src/utils/assignment-rules'; | } from "../../src/utils/assignment-rules"; | ||||||
| 
 | 
 | ||||||
| describe('Validation Rules', () => { | describe("Validation Rules", () => { | ||||||
|     describe('assignmentTitleRules', () => { |     describe("assignmentTitleRules", () => { | ||||||
|         it('should return true for a valid title', () => { |         it("should return true for a valid title", () => { | ||||||
|             const result = assignmentTitleRules[0]('Valid Title'); |             const result = assignmentTitleRules[0]("Valid Title"); | ||||||
|             expect(result).toBe(true); |             expect(result).toBe(true); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an empty title', () => { |         it("should return an error message for an empty title", () => { | ||||||
|             const result = assignmentTitleRules[0](''); |             const result = assignmentTitleRules[0](""); | ||||||
|             expect(result).toBe('Title cannot be empty.'); |             expect(result).toBe("Title cannot be empty."); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     describe('learningPathRules', () => { |     describe("learningPathRules", () => { | ||||||
|         it('should return true for a valid learning path', () => { |         it("should return true for a valid learning path", () => { | ||||||
|             const result = learningPathRules[0]({ hruid: '123', title: 'Path Title' }); |             const result = learningPathRules[0]({ hruid: "123", title: "Path Title" }); | ||||||
|             expect(result).toBe(true); |             expect(result).toBe(true); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an invalid learning path', () => { |         it("should return an error message for an invalid learning path", () => { | ||||||
|             const result = learningPathRules[0]({ hruid: '', title: '' }); |             const result = learningPathRules[0]({ hruid: "", title: "" }); | ||||||
|             expect(result).toBe('You must select a learning path.'); |             expect(result).toBe("You must select a learning path."); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     describe('classRules', () => { |     describe("classRules", () => { | ||||||
|         it('should return true for a valid class', () => { |         it("should return true for a valid class", () => { | ||||||
|             const result = classRules[0]('Class 1'); |             const result = classRules[0]("Class 1"); | ||||||
|             expect(result).toBe(true); |             expect(result).toBe(true); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an empty class', () => { |         it("should return an error message for an empty class", () => { | ||||||
|             const result = classRules[0](''); |             const result = classRules[0](""); | ||||||
|             expect(result).toBe('You must select at least one class.'); |             expect(result).toBe("You must select at least one class."); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     describe('deadlineRules', () => { |     describe("deadlineRules", () => { | ||||||
|         it('should return true for a valid future deadline', () => { |         it("should return true for a valid future deadline", () => { | ||||||
|             const futureDate = new Date(Date.now() + 1000 * 60 * 60).toISOString(); |             const futureDate = new Date(Date.now() + 1000 * 60 * 60).toISOString(); | ||||||
|             const result = deadlineRules[0](futureDate); |             const result = deadlineRules[0](futureDate); | ||||||
|             expect(result).toBe(true); |             expect(result).toBe(true); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for a past deadline', () => { |         it("should return an error message for a past deadline", () => { | ||||||
|             const pastDate = new Date(Date.now() - 1000 * 60 * 60).toISOString(); |             const pastDate = new Date(Date.now() - 1000 * 60 * 60).toISOString(); | ||||||
|             const result = deadlineRules[0](pastDate); |             const result = deadlineRules[0](pastDate); | ||||||
|             expect(result).toBe('The deadline must be in the future.'); |             expect(result).toBe("The deadline must be in the future."); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an invalid date', () => { |         it("should return an error message for an invalid date", () => { | ||||||
|             const result = deadlineRules[0]('invalid-date'); |             const result = deadlineRules[0]("invalid-date"); | ||||||
|             expect(result).toBe('Invalid date or time.'); |             expect(result).toBe("Invalid date or time."); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an empty deadline', () => { |         it("should return an error message for an empty deadline", () => { | ||||||
|             const result = deadlineRules[0](''); |             const result = deadlineRules[0](""); | ||||||
|             expect(result).toBe('You must set a deadline.'); |             expect(result).toBe("You must set a deadline."); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     describe('descriptionRules', () => { |     describe("descriptionRules", () => { | ||||||
|         it('should return true for a valid description', () => { |         it("should return true for a valid description", () => { | ||||||
|             const result = descriptionRules[0]('This is a valid description.'); |             const result = descriptionRules[0]("This is a valid description."); | ||||||
|             expect(result).toBe(true); |             expect(result).toBe(true); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         it('should return an error message for an empty description', () => { |         it("should return an error message for an empty description", () => { | ||||||
|             const result = descriptionRules[0](''); |             const result = descriptionRules[0](""); | ||||||
|             expect(result).toBe('Description cannot be empty.'); |             expect(result).toBe("Description cannot be empty."); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,68 +1,68 @@ | ||||||
| import { describe, it, expect } from 'vitest'; | import { describe, it, expect } from "vitest"; | ||||||
| import { deepEquals } from '../../src/utils/deep-equals'; | import { deepEquals } from "../../src/utils/deep-equals"; | ||||||
| 
 | 
 | ||||||
| describe('deepEquals', () => { | describe("deepEquals", () => { | ||||||
|   it('should return true for identical primitive values', () => { |     it("should return true for identical primitive values", () => { | ||||||
|     expect(deepEquals(1, 1)).toBe(true); |         expect(deepEquals(1, 1)).toBe(true); | ||||||
|     expect(deepEquals('test', 'test')).toBe(true); |         expect(deepEquals("test", "test")).toBe(true); | ||||||
|     expect(deepEquals(true, true)).toBe(true); |         expect(deepEquals(true, true)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for different primitive values', () => { |     it("should return false for different primitive values", () => { | ||||||
|     expect(deepEquals(1, 2)).toBe(false); |         expect(deepEquals(1, 2)).toBe(false); | ||||||
|     expect(deepEquals('test', 'other')).toBe(false); |         expect(deepEquals("test", "other")).toBe(false); | ||||||
|     expect(deepEquals(true, false)).toBe(false); |         expect(deepEquals(true, false)).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return true for identical objects', () => { |     it("should return true for identical objects", () => { | ||||||
|     const obj1 = { a: 1, b: { c: 2 } }; |         const obj1 = { a: 1, b: { c: 2 } }; | ||||||
|     const obj2 = { a: 1, b: { c: 2 } }; |         const obj2 = { a: 1, b: { c: 2 } }; | ||||||
|     expect(deepEquals(obj1, obj2)).toBe(true); |         expect(deepEquals(obj1, obj2)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for different objects', () => { |     it("should return false for different objects", () => { | ||||||
|     const obj1 = { a: 1, b: { c: 2 } }; |         const obj1 = { a: 1, b: { c: 2 } }; | ||||||
|     const obj2 = { a: 1, b: { c: 3 } }; |         const obj2 = { a: 1, b: { c: 3 } }; | ||||||
|     expect(deepEquals(obj1, obj2)).toBe(false); |         expect(deepEquals(obj1, obj2)).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return true for identical arrays', () => { |     it("should return true for identical arrays", () => { | ||||||
|     const arr1 = [1, 2, [3, 4]]; |         const arr1 = [1, 2, [3, 4]]; | ||||||
|     const arr2 = [1, 2, [3, 4]]; |         const arr2 = [1, 2, [3, 4]]; | ||||||
|     expect(deepEquals(arr1, arr2)).toBe(true); |         expect(deepEquals(arr1, arr2)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for different arrays', () => { |     it("should return false for different arrays", () => { | ||||||
|     const arr1 = [1, 2, [3, 4]]; |         const arr1 = [1, 2, [3, 4]]; | ||||||
|     const arr2 = [1, 2, [3, 5]]; |         const arr2 = [1, 2, [3, 5]]; | ||||||
|     expect(deepEquals(arr1, arr2)).toBe(false); |         expect(deepEquals(arr1, arr2)).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for objects and arrays compared', () => { |     it("should return false for objects and arrays compared", () => { | ||||||
|     expect(deepEquals({ a: 1 }, [1])).toBe(false); |         expect(deepEquals({ a: 1 }, [1])).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return true for null compared to null', () => { |     it("should return true for null compared to null", () => { | ||||||
|     expect(deepEquals(null, null)).toBe(true); |         expect(deepEquals(null, null)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for null compared to an object', () => { |     it("should return false for null compared to an object", () => { | ||||||
|     expect(deepEquals(null, {})).toBe(false); |         expect(deepEquals(null, {})).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for undefined compared to null', () => { |     it("should return false for undefined compared to null", () => { | ||||||
|     expect(deepEquals(undefined, null)).toBe(false); |         expect(deepEquals(undefined, null)).toBe(false); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return true for deeply nested identical structures', () => { |     it("should return true for deeply nested identical structures", () => { | ||||||
|     const obj1 = { a: [1, { b: 2, c: [3, 4] }] }; |         const obj1 = { a: [1, { b: 2, c: [3, 4] }] }; | ||||||
|     const obj2 = { a: [1, { b: 2, c: [3, 4] }] }; |         const obj2 = { a: [1, { b: 2, c: [3, 4] }] }; | ||||||
|     expect(deepEquals(obj1, obj2)).toBe(true); |         expect(deepEquals(obj1, obj2)).toBe(true); | ||||||
|   }); |     }); | ||||||
| 
 | 
 | ||||||
|   it('should return false for deeply nested different structures', () => { |     it("should return false for deeply nested different structures", () => { | ||||||
|     const obj1 = { a: [1, { b: 2, c: [3, 4] }] }; |         const obj1 = { a: [1, { b: 2, c: [3, 4] }] }; | ||||||
|     const obj2 = { a: [1, { b: 2, c: [3, 5] }] }; |         const obj2 = { a: [1, { b: 2, c: [3, 5] }] }; | ||||||
|     expect(deepEquals(obj1, obj2)).toBe(false); |         expect(deepEquals(obj1, obj2)).toBe(false); | ||||||
|   }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Lint Action
						Lint Action