refactor(backend): Functions
This commit is contained in:
parent
5ec62554e3
commit
65c1a5e6b6
57 changed files with 172 additions and 117 deletions
|
@ -78,7 +78,7 @@ describe('DatabaseLearningObjectProvider', () => {
|
|||
});
|
||||
it('should throw an error if queried with a path identifier for which there is no learning path', async () => {
|
||||
await expect(
|
||||
(async () => {
|
||||
(async (): Promise<void> => {
|
||||
await databaseLearningObjectProvider.getLearningObjectIdsFromPath({
|
||||
hruid: 'non_existing_hruid',
|
||||
language: Language.Dutch,
|
||||
|
@ -97,7 +97,7 @@ describe('DatabaseLearningObjectProvider', () => {
|
|||
});
|
||||
it('should throw an error if queried with a path identifier for which there is no learning path', async () => {
|
||||
await expect(
|
||||
(async () => {
|
||||
(async (): Promise<void> => {
|
||||
await databaseLearningObjectProvider.getLearningObjectsFromPath({
|
||||
hruid: 'non_existing_hruid',
|
||||
language: Language.Dutch,
|
||||
|
|
|
@ -124,7 +124,7 @@ describe('DatabaseLearningPathProvider', () => {
|
|||
|
||||
const learningObjectsOnPath = (
|
||||
await Promise.all(
|
||||
example.learningPath.nodes.map((node) =>
|
||||
example.learningPath.nodes.map(async (node) =>
|
||||
learningObjectService.getLearningObjectById({
|
||||
hruid: node.learningObjectHruid,
|
||||
version: node.version,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { makeTestQuestions } from './test_assets/questions/questions.testdata.js
|
|||
import { makeTestAnswers } from './test_assets/questions/answers.testdata.js';
|
||||
import { makeTestSubmissions } from './test_assets/assignments/submission.testdata.js';
|
||||
|
||||
export async function setupTestApp() {
|
||||
export async function setupTestApp(): Promise<void> {
|
||||
dotenv.config({ path: '.env.test' });
|
||||
await initORM(true);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { envVars, getEnvVar } from '../../../../src/util/envVars';
|
|||
*/
|
||||
export function dummyLearningObject(hruid: string, language: Language, title: string): LearningObjectExample {
|
||||
return {
|
||||
createLearningObject: () => {
|
||||
createLearningObject: (): LearningObject => {
|
||||
const learningObject = new LearningObject();
|
||||
learningObject.hruid = getEnvVar(envVars.UserContentPrefix) + hruid;
|
||||
learningObject.language = language;
|
||||
|
|
|
@ -3,7 +3,12 @@ import { LearningPathTransition } from '../../../src/entities/content/learning-p
|
|||
import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity';
|
||||
import { LearningPath } from '../../../src/entities/content/learning-path.entity';
|
||||
|
||||
export function createLearningPathTransition(node: LearningPathNode, transitionNumber: number, condition: string | null, to: LearningPathNode) {
|
||||
export function createLearningPathTransition(
|
||||
node: LearningPathNode,
|
||||
transitionNumber: number,
|
||||
condition: string | null,
|
||||
to: LearningPathNode
|
||||
): LearningPathTransition {
|
||||
const trans = new LearningPathTransition();
|
||||
trans.node = node;
|
||||
trans.transitionNumber = transitionNumber;
|
||||
|
@ -19,7 +24,7 @@ export function createLearningPathNode(
|
|||
version: number,
|
||||
language: Language,
|
||||
startNode: boolean
|
||||
) {
|
||||
): LearningPathNode {
|
||||
const node = new LearningPathNode();
|
||||
node.learningPath = learningPath;
|
||||
node.nodeNumber = nodeNumber;
|
||||
|
|
|
@ -69,7 +69,7 @@ export function expectToBeCorrectEntity<T extends object>(actual: { entity: T; n
|
|||
* @param filtered the representation as FilteredLearningObject
|
||||
* @param original the original entity added to the database
|
||||
*/
|
||||
export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: LearningObject) {
|
||||
export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: LearningObject): void {
|
||||
expect(filtered.uuid).toEqual(original.uuid);
|
||||
expect(filtered.version).toEqual(original.version);
|
||||
expect(filtered.language).toEqual(original.language);
|
||||
|
@ -105,7 +105,7 @@ export function expectToBeCorrectLearningPath(
|
|||
learningPath: LearningPath,
|
||||
expectedEntity: LearningPathEntity,
|
||||
learningObjectsOnPath: FilteredLearningObject[]
|
||||
) {
|
||||
): void {
|
||||
expect(learningPath.hruid).toEqual(expectedEntity.hruid);
|
||||
expect(learningPath.language).toEqual(expectedEntity.language);
|
||||
expect(learningPath.description).toEqual(expectedEntity.description);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue