style: fix linting issues met Prettier
This commit is contained in:
parent
28e0a7b45d
commit
75d80f65f5
3 changed files with 54 additions and 57 deletions
|
@ -1,17 +1,12 @@
|
|||
import {LearningObjectProvider} from "./learning-object-provider";
|
||||
import {
|
||||
FilteredLearningObject,
|
||||
LearningObjectIdentifier,
|
||||
LearningPathIdentifier
|
||||
} from "../../interfaces/learning-content";
|
||||
import {getLearningObjectRepository, getLearningPathRepository} from "../../data/repositories";
|
||||
import {Language} from "../../entities/content/language";
|
||||
import {LearningObject} from "../../entities/content/learning-object.entity";
|
||||
import {getUrlStringForLearningObject} from "../../util/links";
|
||||
import processingService from "./processing/processing-service";
|
||||
import {NotFoundError} from "@mikro-orm/core";
|
||||
import learningObjectService from "./learning-object-service";
|
||||
|
||||
import { LearningObjectProvider } from './learning-object-provider';
|
||||
import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '../../interfaces/learning-content';
|
||||
import { getLearningObjectRepository, getLearningPathRepository } from '../../data/repositories';
|
||||
import { Language } from '../../entities/content/language';
|
||||
import { LearningObject } from '../../entities/content/learning-object.entity';
|
||||
import { getUrlStringForLearningObject } from '../../util/links';
|
||||
import processingService from './processing/processing-service';
|
||||
import { NotFoundError } from '@mikro-orm/core';
|
||||
import learningObjectService from './learning-object-service';
|
||||
|
||||
function convertLearningObject(learningObject: LearningObject | null): FilteredLearningObject | null {
|
||||
if (!learningObject) {
|
||||
|
@ -110,8 +105,8 @@ const databaseLearningObjectProvider: LearningObjectProvider = {
|
|||
return learningObject;
|
||||
})
|
||||
);
|
||||
return learningObjects.filter(it => it !== null);
|
||||
}
|
||||
return learningObjects.filter((it) => it !== null);
|
||||
},
|
||||
};
|
||||
|
||||
export default databaseLearningObjectProvider;
|
||||
|
|
|
@ -1 +1 @@
|
|||
type PointOfView = {type: "student", student: Student} | {type: "group", group: Group};
|
||||
type PointOfView = { type: 'student'; student: Student } | { type: 'group'; group: Group };
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import {beforeAll, describe, expect, it} from "vitest";
|
||||
import {setupTestApp} from "../../setup-tests";
|
||||
import {getLearningObjectRepository, getLearningPathRepository} from "../../../src/data/repositories";
|
||||
import example from "../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example";
|
||||
import {LearningObject} from "../../../src/entities/content/learning-object.entity";
|
||||
import databaseLearningObjectProvider from "../../../src/services/learning-objects/database-learning-object-provider";
|
||||
import {expectToBeCorrectFilteredLearningObject} from "../../test-utils/expectations";
|
||||
import {FilteredLearningObject} from "../../../src/interfaces/learning-content";
|
||||
import {Language} from "../../../src/entities/content/language";
|
||||
import learningObjectExample from "../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example";
|
||||
import learningPathExample from "../../test-assets/learning-paths/pn-werking-example";
|
||||
import {LearningPath} from "../../../src/entities/content/learning-path.entity";
|
||||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { setupTestApp } from '../../setup-tests';
|
||||
import { getLearningObjectRepository, getLearningPathRepository } from '../../../src/data/repositories';
|
||||
import example from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example';
|
||||
import { LearningObject } from '../../../src/entities/content/learning-object.entity';
|
||||
import databaseLearningObjectProvider from '../../../src/services/learning-objects/database-learning-object-provider';
|
||||
import { expectToBeCorrectFilteredLearningObject } from '../../test-utils/expectations';
|
||||
import { FilteredLearningObject } from '../../../src/interfaces/learning-content';
|
||||
import { Language } from '../../../src/entities/content/language';
|
||||
import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example';
|
||||
import learningPathExample from '../../test-assets/learning-paths/pn-werking-example';
|
||||
import { LearningPath } from '../../../src/entities/content/learning-path.entity';
|
||||
|
||||
async function initExampleData(): Promise<{learningObject: LearningObject, learningPath: LearningPath}> {
|
||||
async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> {
|
||||
const learningObjectRepo = getLearningObjectRepository();
|
||||
const learningPathRepo = getLearningPathRepository();
|
||||
const learningObject = learningObjectExample.createLearningObject();
|
||||
|
@ -21,7 +21,7 @@ async function initExampleData(): Promise<{learningObject: LearningObject, learn
|
|||
return { learningObject, learningPath };
|
||||
}
|
||||
|
||||
const EXPECTED_TITLE_FROM_DWENGO_LEARNING_OBJECT = "Notebook opslaan";
|
||||
const EXPECTED_TITLE_FROM_DWENGO_LEARNING_OBJECT = 'Notebook opslaan';
|
||||
|
||||
describe('DatabaseLearningObjectProvider', () => {
|
||||
let exampleLearningObject: LearningObject;
|
||||
|
@ -62,45 +62,47 @@ describe('DatabaseLearningObjectProvider', () => {
|
|||
const result = await databaseLearningObjectProvider.getLearningObjectHTML(exampleLearningObject);
|
||||
expect(result).toEqual(example.getHTMLRendering());
|
||||
});
|
||||
it("should return null for a non-existing learning object", async () => {
|
||||
it('should return null for a non-existing learning object', async () => {
|
||||
const result = await databaseLearningObjectProvider.getLearningObjectHTML({
|
||||
hruid: "non_existing_hruid",
|
||||
language: Language.Dutch
|
||||
hruid: 'non_existing_hruid',
|
||||
language: Language.Dutch,
|
||||
});
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
describe("getLearningObjectIdsFromPath", () => {
|
||||
it("should return all learning object IDs from a path", async () => {
|
||||
describe('getLearningObjectIdsFromPath', () => {
|
||||
it('should return all learning object IDs from a path', async () => {
|
||||
const result = await databaseLearningObjectProvider.getLearningObjectIdsFromPath(exampleLearningPath);
|
||||
expect(new Set(result))
|
||||
.toEqual(new Set(exampleLearningPath.nodes.map(it => it.learningObjectHruid)));
|
||||
expect(new Set(result)).toEqual(new Set(exampleLearningPath.nodes.map((it) => it.learningObjectHruid)));
|
||||
});
|
||||
it("should throw an error if queried with a path identifier for which there is no learning path", async () => {
|
||||
await expect((async () => {
|
||||
await databaseLearningObjectProvider.getLearningObjectIdsFromPath({
|
||||
hruid: "non_existing_hruid",
|
||||
language: Language.Dutch
|
||||
});
|
||||
})()).rejects.toThrowError();
|
||||
it('should throw an error if queried with a path identifier for which there is no learning path', async () => {
|
||||
await expect(
|
||||
(async () => {
|
||||
await databaseLearningObjectProvider.getLearningObjectIdsFromPath({
|
||||
hruid: 'non_existing_hruid',
|
||||
language: Language.Dutch,
|
||||
});
|
||||
})()
|
||||
).rejects.toThrowError();
|
||||
});
|
||||
});
|
||||
describe("getLearningObjectsFromPath", () => {
|
||||
it("should correctly return all learning objects which are on the path, even those who are not in the database", async () => {
|
||||
describe('getLearningObjectsFromPath', () => {
|
||||
it('should correctly return all learning objects which are on the path, even those who are not in the database', async () => {
|
||||
const result = await databaseLearningObjectProvider.getLearningObjectsFromPath(exampleLearningPath);
|
||||
expect(result.length).toBe(exampleLearningPath.nodes.length);
|
||||
expect(new Set(result.map(it => it.key)))
|
||||
.toEqual(new Set(exampleLearningPath.nodes.map(it => it.learningObjectHruid)));
|
||||
expect(new Set(result.map((it) => it.key))).toEqual(new Set(exampleLearningPath.nodes.map((it) => it.learningObjectHruid)));
|
||||
|
||||
expect(result.map(it => it.title)).toContainEqual(EXPECTED_TITLE_FROM_DWENGO_LEARNING_OBJECT);
|
||||
expect(result.map((it) => it.title)).toContainEqual(EXPECTED_TITLE_FROM_DWENGO_LEARNING_OBJECT);
|
||||
});
|
||||
it("should throw an error if queried with a path identifier for which there is no learning path", async () => {
|
||||
await expect((async () => {
|
||||
await databaseLearningObjectProvider.getLearningObjectsFromPath({
|
||||
hruid: "non_existing_hruid",
|
||||
language: Language.Dutch
|
||||
});
|
||||
})()).rejects.toThrowError();
|
||||
it('should throw an error if queried with a path identifier for which there is no learning path', async () => {
|
||||
await expect(
|
||||
(async () => {
|
||||
await databaseLearningObjectProvider.getLearningObjectsFromPath({
|
||||
hruid: 'non_existing_hruid',
|
||||
language: Language.Dutch,
|
||||
});
|
||||
})()
|
||||
).rejects.toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue