style: fix linting issues met Prettier
This commit is contained in:
		
							parent
							
								
									aa1a85e64e
								
							
						
					
					
						commit
						2a2881ec30
					
				
					 84 changed files with 846 additions and 1013 deletions
				
			
		|  | @ -1,30 +1,30 @@ | |||
| import {beforeAll, describe, expect, it} from "vitest"; | ||||
| import {setupTestApp} from "../../setup-tests"; | ||||
| import {LearningObject} from "../../../src/entities/content/learning-object.entity"; | ||||
| import {getLearningObjectRepository} from "../../../src/data/repositories"; | ||||
| import learningObjectExample from "../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example"; | ||||
| import learningObjectService from "../../../src/services/learning-objects/learning-object-service"; | ||||
| import {LearningObjectIdentifier} from "../../../src/interfaces/learning-content"; | ||||
| import {Language} from "../../../src/entities/content/language"; | ||||
| import {EnvVars, getEnvVar} from "../../../src/util/envvars"; | ||||
| import { beforeAll, describe, expect, it } from 'vitest'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { getLearningObjectRepository } from '../../../src/data/repositories'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service'; | ||||
| import { LearningObjectIdentifier } from '../../../src/interfaces/learning-content'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { EnvVars, getEnvVar } from '../../../src/util/envvars'; | ||||
| 
 | ||||
| const TEST_LEARNING_OBJECT_TITLE = "Test title"; | ||||
| const EXPECTED_DWENGO_LEARNING_OBJECT_TITLE = "Werken met notebooks"; | ||||
| const TEST_LEARNING_OBJECT_TITLE = 'Test title'; | ||||
| const EXPECTED_DWENGO_LEARNING_OBJECT_TITLE = 'Werken met notebooks'; | ||||
| const DWENGO_TEST_LEARNING_OBJECT_ID: LearningObjectIdentifier = { | ||||
|     hruid: "pn_werkingnotebooks", | ||||
|     hruid: 'pn_werkingnotebooks', | ||||
|     language: Language.Dutch, | ||||
|     version: 3 | ||||
|     version: 3, | ||||
| }; | ||||
| 
 | ||||
| async function initExampleData(): Promise<LearningObject> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|     const learningObject = learningObjectExample.createLearningObject(); | ||||
|     learningObject.title = TEST_LEARNING_OBJECT_TITLE | ||||
|     learningObject.title = TEST_LEARNING_OBJECT_TITLE; | ||||
|     await learningObjectRepo.save(learningObject); | ||||
|     return learningObject; | ||||
| } | ||||
| 
 | ||||
| describe("LearningObjectService", () => { | ||||
| describe('LearningObjectService', () => { | ||||
|     let exampleLearningObject: LearningObject; | ||||
| 
 | ||||
|     beforeAll(async () => { | ||||
|  | @ -32,47 +32,50 @@ describe("LearningObjectService", () => { | |||
|         exampleLearningObject = await initExampleData(); | ||||
|     }); | ||||
| 
 | ||||
|     describe("getLearningObjectById", () => { | ||||
|         it("returns the learning object from the Dwengo API if it does not have the user content prefix", async () => { | ||||
|     describe('getLearningObjectById', () => { | ||||
|         it('returns the learning object from the Dwengo API if it does not have the user content prefix', async () => { | ||||
|             const result = await learningObjectService.getLearningObjectById(DWENGO_TEST_LEARNING_OBJECT_ID); | ||||
|             expect(result).not.toBeNull(); | ||||
|             expect(result?.title).toBe(EXPECTED_DWENGO_LEARNING_OBJECT_TITLE); | ||||
|         }); | ||||
|         it("returns the learning object from the database if it does have the user content prefix", async () => { | ||||
|         it('returns the learning object from the database if it does have the user content prefix', async () => { | ||||
|             const result = await learningObjectService.getLearningObjectById(exampleLearningObject); | ||||
|             expect(result).not.toBeNull(); | ||||
|             expect(result?.title).toBe(exampleLearningObject.title); | ||||
|         }); | ||||
|         it("returns null if the hruid does not have the user content prefix and does not exist in the Dwengo repo", async () => { | ||||
|         it('returns null if the hruid does not have the user content prefix and does not exist in the Dwengo repo', async () => { | ||||
|             const result = await learningObjectService.getLearningObjectById({ | ||||
|                 hruid: "non-existing", | ||||
|                 language: Language.Dutch | ||||
|                 hruid: 'non-existing', | ||||
|                 language: Language.Dutch, | ||||
|             }); | ||||
|             expect(result).toBeNull(); | ||||
|         }); | ||||
|     }); | ||||
| 
 | ||||
|     describe("getLearningObjectHTML", () => { | ||||
|         it("returns the expected HTML when queried with the identifier of a learning object saved in the database", async () => { | ||||
|     describe('getLearningObjectHTML', () => { | ||||
|         it('returns the expected HTML when queried with the identifier of a learning object saved in the database', async () => { | ||||
|             const result = await learningObjectService.getLearningObjectHTML(exampleLearningObject); | ||||
|             expect(result).not.toBeNull(); | ||||
|             expect(result).toEqual(learningObjectExample.getHTMLRendering()); | ||||
|         }); | ||||
|         it("returns the same HTML as the Dwengo API when queried with the identifier of a learning object that does " + | ||||
|             "not start with the user content prefix", async () => { | ||||
|             const result = await learningObjectService.getLearningObjectHTML(DWENGO_TEST_LEARNING_OBJECT_ID); | ||||
|             expect(result).not.toBeNull(); | ||||
|         it( | ||||
|             'returns the same HTML as the Dwengo API when queried with the identifier of a learning object that does ' + | ||||
|                 'not start with the user content prefix', | ||||
|             async () => { | ||||
|                 const result = await learningObjectService.getLearningObjectHTML(DWENGO_TEST_LEARNING_OBJECT_ID); | ||||
|                 expect(result).not.toBeNull(); | ||||
| 
 | ||||
|             const htmlFromDwengoApi = await fetch( | ||||
|                 getEnvVar(EnvVars.LearningContentRepoApiBaseUrl) | ||||
|                 + `/learningObject/getRaw?hruid=${DWENGO_TEST_LEARNING_OBJECT_ID.hruid}&language=${DWENGO_TEST_LEARNING_OBJECT_ID.language}&version=${DWENGO_TEST_LEARNING_OBJECT_ID.version}` | ||||
|             ).then(it => it.text()); | ||||
|             expect(result).toEqual(htmlFromDwengoApi); | ||||
|         }); | ||||
|         it("returns null when queried with a non-existing identifier", async () => { | ||||
|                 const htmlFromDwengoApi = await fetch( | ||||
|                     getEnvVar(EnvVars.LearningContentRepoApiBaseUrl) + | ||||
|                         `/learningObject/getRaw?hruid=${DWENGO_TEST_LEARNING_OBJECT_ID.hruid}&language=${DWENGO_TEST_LEARNING_OBJECT_ID.language}&version=${DWENGO_TEST_LEARNING_OBJECT_ID.version}` | ||||
|                 ).then((it) => it.text()); | ||||
|                 expect(result).toEqual(htmlFromDwengoApi); | ||||
|             } | ||||
|         ); | ||||
|         it('returns null when queried with a non-existing identifier', async () => { | ||||
|             const result = await learningObjectService.getLearningObjectHTML({ | ||||
|                 hruid: "non_existing_hruid", | ||||
|                 language: Language.Dutch | ||||
|                 hruid: 'non_existing_hruid', | ||||
|                 language: Language.Dutch, | ||||
|             }); | ||||
|             expect(result).toBeNull(); | ||||
|         }); | ||||
|  |  | |||
		Reference in a new issue
	
	 Lint Action
						Lint Action