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