mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
Update Tests for HD_SHOW_LOG_TIMESTAMP
Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
parent
8f66447ab9
commit
ece2bc2880
2 changed files with 47 additions and 0 deletions
|
@ -18,6 +18,7 @@ describe('appConfig', () => {
|
||||||
const outOfRangePort = 1000000;
|
const outOfRangePort = 1000000;
|
||||||
const invalidPort = 'not-a-port';
|
const invalidPort = 'not-a-port';
|
||||||
const loglevel = Loglevel.TRACE;
|
const loglevel = Loglevel.TRACE;
|
||||||
|
const showLogTimestamp = false;
|
||||||
const invalidLoglevel = 'not-a-loglevel';
|
const invalidLoglevel = 'not-a-loglevel';
|
||||||
const invalidPersistInterval = -1;
|
const invalidPersistInterval = -1;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ describe('appConfig', () => {
|
||||||
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_PERSIST_INTERVAL: '100',
|
HD_PERSIST_INTERVAL: '100',
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
@ -42,6 +44,7 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
expect(config.port).toEqual(port);
|
expect(config.port).toEqual(port);
|
||||||
expect(config.loglevel).toEqual(loglevel);
|
expect(config.loglevel).toEqual(loglevel);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
expect(config.persistInterval).toEqual(100);
|
expect(config.persistInterval).toEqual(100);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
@ -53,6 +56,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_PERSIST_INTERVAL: '100',
|
HD_PERSIST_INTERVAL: '100',
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
@ -65,6 +69,7 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(baseUrl);
|
expect(config.rendererBaseUrl).toEqual(baseUrl);
|
||||||
expect(config.port).toEqual(port);
|
expect(config.port).toEqual(port);
|
||||||
expect(config.loglevel).toEqual(loglevel);
|
expect(config.loglevel).toEqual(loglevel);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
expect(config.persistInterval).toEqual(100);
|
expect(config.persistInterval).toEqual(100);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
@ -76,6 +81,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_PERSIST_INTERVAL: '100',
|
HD_PERSIST_INTERVAL: '100',
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
@ -88,6 +94,7 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
expect(config.port).toEqual(3000);
|
expect(config.port).toEqual(3000);
|
||||||
expect(config.loglevel).toEqual(loglevel);
|
expect(config.loglevel).toEqual(loglevel);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
expect(config.persistInterval).toEqual(100);
|
expect(config.persistInterval).toEqual(100);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
@ -99,6 +106,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_PERSIST_INTERVAL: '100',
|
HD_PERSIST_INTERVAL: '100',
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
@ -111,6 +119,7 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
expect(config.port).toEqual(port);
|
expect(config.port).toEqual(port);
|
||||||
expect(config.loglevel).toEqual(Loglevel.WARN);
|
expect(config.loglevel).toEqual(Loglevel.WARN);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
expect(config.persistInterval).toEqual(100);
|
expect(config.persistInterval).toEqual(100);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
@ -122,6 +131,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
@ -134,11 +144,37 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
expect(config.port).toEqual(port);
|
expect(config.port).toEqual(port);
|
||||||
expect(config.loglevel).toEqual(Loglevel.TRACE);
|
expect(config.loglevel).toEqual(Loglevel.TRACE);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
expect(config.persistInterval).toEqual(10);
|
expect(config.persistInterval).toEqual(10);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('when HD_PERSIST_INTERVAL is zero', () => {
|
it('when HD_PERSIST_INTERVAL is zero', () => {
|
||||||
|
const restore = mockedEnv(
|
||||||
|
{
|
||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
HD_BASE_URL: baseUrl,
|
||||||
|
HD_RENDERER_BASE_URL: rendererBaseUrl,
|
||||||
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
|
HD_BACKEND_PORT: port.toString(),
|
||||||
|
HD_PERSIST_INTERVAL: '0',
|
||||||
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
clear: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const config = appConfig();
|
||||||
|
expect(config.baseUrl).toEqual(baseUrl);
|
||||||
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
|
expect(config.port).toEqual(port);
|
||||||
|
expect(config.loglevel).toEqual(Loglevel.TRACE);
|
||||||
|
expect(config.showLogTimestamp).toEqual(showLogTimestamp);
|
||||||
|
expect(config.persistInterval).toEqual(0);
|
||||||
|
restore();
|
||||||
|
});
|
||||||
|
it('when no HD_SHOW_LOG_TIMESTAMP is set', () => {
|
||||||
const restore = mockedEnv(
|
const restore = mockedEnv(
|
||||||
{
|
{
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
@ -158,6 +194,7 @@ describe('appConfig', () => {
|
||||||
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
expect(config.rendererBaseUrl).toEqual(rendererBaseUrl);
|
||||||
expect(config.port).toEqual(port);
|
expect(config.port).toEqual(port);
|
||||||
expect(config.loglevel).toEqual(Loglevel.TRACE);
|
expect(config.loglevel).toEqual(Loglevel.TRACE);
|
||||||
|
expect(config.showLogTimestamp).toEqual(true);
|
||||||
expect(config.persistInterval).toEqual(0);
|
expect(config.persistInterval).toEqual(0);
|
||||||
restore();
|
restore();
|
||||||
});
|
});
|
||||||
|
@ -170,6 +207,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: invalidBaseUrl,
|
HD_BASE_URL: invalidBaseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -186,6 +224,7 @@ describe('appConfig', () => {
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
HD_BASE_URL: 'https://example.org/subdirectory/',
|
HD_BASE_URL: 'https://example.org/subdirectory/',
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -205,6 +244,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: negativePort.toString(),
|
HD_BACKEND_PORT: negativePort.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -224,6 +264,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: outOfRangePort.toString(),
|
HD_BACKEND_PORT: outOfRangePort.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -243,6 +284,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: floatPort.toString(),
|
HD_BACKEND_PORT: floatPort.toString(),
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -260,6 +302,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: invalidPort,
|
HD_BACKEND_PORT: invalidPort,
|
||||||
HD_LOGLEVEL: loglevel,
|
HD_LOGLEVEL: loglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -277,6 +320,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
HD_LOGLEVEL: invalidLoglevel,
|
HD_LOGLEVEL: invalidLoglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -294,6 +338,7 @@ describe('appConfig', () => {
|
||||||
HD_BASE_URL: baseUrl,
|
HD_BASE_URL: baseUrl,
|
||||||
HD_BACKEND_PORT: port.toString(),
|
HD_BACKEND_PORT: port.toString(),
|
||||||
HD_LOGLEVEL: invalidLoglevel,
|
HD_LOGLEVEL: invalidLoglevel,
|
||||||
|
HD_SHOW_LOG_TIMESTAMP: showLogTimestamp.toString(),
|
||||||
HD_PERSIST_INTERVAL: invalidPersistInterval.toString(),
|
HD_PERSIST_INTERVAL: invalidPersistInterval.toString(),
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
},
|
},
|
||||||
|
|
|
@ -141,6 +141,7 @@ describe('FrontendConfigService', () => {
|
||||||
rendererBaseUrl: 'https://renderer.example.org',
|
rendererBaseUrl: 'https://renderer.example.org',
|
||||||
port: 3000,
|
port: 3000,
|
||||||
loglevel: Loglevel.ERROR,
|
loglevel: Loglevel.ERROR,
|
||||||
|
showLogTimestamp: false,
|
||||||
persistInterval: 10,
|
persistInterval: 10,
|
||||||
};
|
};
|
||||||
const authConfig: AuthConfig = {
|
const authConfig: AuthConfig = {
|
||||||
|
@ -284,6 +285,7 @@ describe('FrontendConfigService', () => {
|
||||||
rendererBaseUrl: 'https://renderer.example.org',
|
rendererBaseUrl: 'https://renderer.example.org',
|
||||||
port: 3000,
|
port: 3000,
|
||||||
loglevel: Loglevel.ERROR,
|
loglevel: Loglevel.ERROR,
|
||||||
|
showLogTimestamp: false,
|
||||||
persistInterval: 10,
|
persistInterval: 10,
|
||||||
};
|
};
|
||||||
const authConfig: AuthConfig = {
|
const authConfig: AuthConfig = {
|
||||||
|
|
Loading…
Reference in a new issue