fix(backend): Testen DatabaseLearningObjectProvider gerepareerd na refactoring.
This commit is contained in:
		
							parent
							
								
									ee9afab6ca
								
							
						
					
					
						commit
						51268af79c
					
				
					 20 changed files with 72 additions and 210 deletions
				
			
		|  | @ -3,6 +3,7 @@ import { LearningObject } from '../../src/entities/content/learning-object.entit | |||
| import { LearningPath as LearningPathEntity } from '../../src/entities/content/learning-path.entity'; | ||||
| import { expect } from 'vitest'; | ||||
| import { FilteredLearningObject, LearningPath } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import {RequiredEntityData} from "@mikro-orm/core"; | ||||
| 
 | ||||
| // Ignored properties because they belang for example to the class, not to the entity itself.
 | ||||
| const IGNORE_PROPERTIES = ['parent']; | ||||
|  | @ -60,9 +61,9 @@ export function expectToBeCorrectEntity<T extends object>( | |||
| /** | ||||
|  * Checks that filtered is the correct representation of original as FilteredLearningObject. | ||||
|  * @param filtered the representation as FilteredLearningObject | ||||
|  * @param original the original entity added to the database | ||||
|  * @param original the data of the entity in the database that was filtered. | ||||
|  */ | ||||
| export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: LearningObject): void { | ||||
| export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: RequiredEntityData<LearningObject>): void { | ||||
|     expect(filtered.uuid).toEqual(original.uuid); | ||||
|     expect(filtered.version).toEqual(original.version); | ||||
|     expect(filtered.language).toEqual(original.language); | ||||
|  |  | |||
							
								
								
									
										12
									
								
								backend/tests/test-utils/get-html-rendering.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								backend/tests/test-utils/get-html-rendering.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| import {RequiredEntityData} from "@mikro-orm/core"; | ||||
| import {loadTestAsset} from "./load-test-asset"; | ||||
| import {LearningObject} from "../../src/entities/content/learning-object.entity"; | ||||
| import {envVars, getEnvVar} from "../../src/util/envVars"; | ||||
| 
 | ||||
| export function getHtmlRenderingForTestLearningObject(learningObject: RequiredEntityData<LearningObject>): string { | ||||
|     const userPrefix = getEnvVar(envVars.UserContentPrefix); | ||||
|     const cleanedHruid = learningObject.hruid.startsWith(userPrefix) | ||||
|                                     ? learningObject.hruid.substring(userPrefix.length) | ||||
|                                     : learningObject.hruid; | ||||
|     return loadTestAsset(`/content/learning-object-resources/${cleanedHruid}/rendering.txt`).toString(); | ||||
| } | ||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger