From 7dd093a44f100ae61f92ec0fe3de5b2268fff531 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 4 Sep 2022 13:08:31 +0200 Subject: [PATCH] test: Add helper functions for creation of mock config Signed-off-by: Tilman Vatteroth --- src/config/mock/note.config.mock.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/config/mock/note.config.mock.ts b/src/config/mock/note.config.mock.ts index 978509545..fe7a02086 100644 --- a/src/config/mock/note.config.mock.ts +++ b/src/config/mock/note.config.mock.ts @@ -3,14 +3,22 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { registerAs } from '@nestjs/config'; +import { ConfigFactoryKeyHost, registerAs } from '@nestjs/config'; +import { ConfigFactory } from '@nestjs/config/dist/interfaces'; import { NoteConfig } from '../note.config'; -export default registerAs( - 'noteConfig', - (): NoteConfig => ({ +export function createDefaultMockNoteConfig(): NoteConfig { + return { maxDocumentLength: 100000, forbiddenNoteIds: ['forbiddenNoteId'], - }), -); + }; +} + +export function registerNoteConfig( + noteConfig: NoteConfig, +): ConfigFactory & ConfigFactoryKeyHost { + return registerAs('noteConfig', (): NoteConfig => noteConfig); +} + +export default registerNoteConfig(createDefaultMockNoteConfig());