fix(backend): Probleem opgelost dat meerdere studenten en leerkrachten met dezelfde PK opgeslagen konden worden.
create() en insert() i.p.v. entity constructoren en persist() gebruikt.
This commit is contained in:
		
							parent
							
								
									295fe23e99
								
							
						
					
					
						commit
						bc94b25a6a
					
				
					 8 changed files with 18 additions and 36 deletions
				
			
		|  | @ -1,5 +1,4 @@ | |||
| import { setupTestApp } from '../../setup-tests.js'; | ||||
| import { Student } from '../../../src/entities/users/student.entity.js'; | ||||
| import { describe, it, expect, beforeAll } from 'vitest'; | ||||
| import { StudentRepository } from '../../../src/data/users/student-repository.js'; | ||||
| import { getStudentRepository } from '../../../src/data/repositories.js'; | ||||
|  | @ -30,7 +29,7 @@ describe('StudentRepository', () => { | |||
|     }); | ||||
| 
 | ||||
|     it('should return the queried student after he was added', async () => { | ||||
|         await studentRepository.insert(new Student(username, firstName, lastName)); | ||||
|         await studentRepository.insert(studentRepository.create({username, firstName, lastName})); | ||||
| 
 | ||||
|         const retrievedStudent = await studentRepository.findByUsername(username); | ||||
|         expect(retrievedStudent).toBeTruthy(); | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ import { describe, it, expect, beforeAll } from 'vitest'; | |||
| import { TeacherRepository } from '../../../src/data/users/teacher-repository'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { getTeacherRepository } from '../../../src/data/repositories'; | ||||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| 
 | ||||
| const username = 'testteacher'; | ||||
| const firstName = 'John'; | ||||
|  | @ -30,7 +29,7 @@ describe('TeacherRepository', () => { | |||
|     }); | ||||
| 
 | ||||
|     it('should return the queried teacher after he was added', async () => { | ||||
|         await teacherRepository.insert(new Teacher(username, firstName, lastName)); | ||||
|         await teacherRepository.insert(teacherRepository.create({username, firstName, lastName})); | ||||
| 
 | ||||
|         const retrievedTeacher = await teacherRepository.findByUsername(username); | ||||
|         expect(retrievedTeacher).toBeTruthy(); | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger