mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 22:35:50 -04:00
fix(config-mocks): adapt all mock config to use create and register functions
This way it's much easier to change the config provided in tests. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
4aadf0bc0d
commit
932075a08f
6 changed files with 113 additions and 37 deletions
|
@ -3,18 +3,26 @@
|
|||
*
|
||||
* 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 { AppConfig } from '../app.config';
|
||||
import { Loglevel } from '../loglevel.enum';
|
||||
|
||||
export default registerAs(
|
||||
'appConfig',
|
||||
(): AppConfig => ({
|
||||
export function createDefaultMockAppConfig(): AppConfig {
|
||||
return {
|
||||
domain: 'md.example.com',
|
||||
rendererBaseUrl: 'md-renderer.example.com',
|
||||
port: 3000,
|
||||
loglevel: Loglevel.ERROR,
|
||||
persistInterval: 10,
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function registerAppConfig(
|
||||
appConfig: AppConfig,
|
||||
): ConfigFactory<AppConfig> & ConfigFactoryKeyHost<AppConfig> {
|
||||
return registerAs('appConfig', (): AppConfig => appConfig);
|
||||
}
|
||||
|
||||
export default registerAppConfig(createDefaultMockAppConfig());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue