test(FrontendConfig): Remove loop over irrelevant variables

Some variables are not used in any logic,
so looping over them does not make any sense.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-05-22 17:29:02 +02:00
parent f3cf4f4b1f
commit d104a98f81

View file

@ -298,24 +298,16 @@ describe('FrontendConfigService', () => {
} }
}); });
const maxDocumentLength = 100000;
const enableRegister = true;
const imageProxy = 'https://imageProxy.example.com';
const customName = 'Test Branding Name';
let index = 1; let index = 1;
for (const renderOrigin of [undefined, 'http://md-renderer.example.com']) { for (const renderOrigin of [undefined, 'http://md-renderer.example.com']) {
for (const maxDocumentLength of [100000, 900]) { for (const customLogo of [undefined, 'https://example.com/logo.png']) {
for (const enableLogin of [true, false]) { for (const privacyLink of [undefined, 'https://example.com/privacy']) {
for (const enableRegister of [true, false]) { for (const termsOfUseLink of [undefined, 'https://example.com/terms']) {
for (const customName of [undefined, 'Test Branding Name']) {
for (const customLogo of [
undefined,
'https://example.com/logo.png',
]) {
for (const privacyLink of [
undefined,
'https://example.com/privacy',
]) {
for (const termsOfUseLink of [
undefined,
'https://example.com/terms',
]) {
for (const imprintLink of [ for (const imprintLink of [
undefined, undefined,
'https://example.com/imprint', 'https://example.com/imprint',
@ -323,10 +315,6 @@ describe('FrontendConfigService', () => {
for (const plantUmlServer of [ for (const plantUmlServer of [
undefined, undefined,
'https://plantuml.example.com', 'https://plantuml.example.com',
]) {
for (const imageProxy of [
undefined,
'https://imageProxy.example.com',
]) { ]) {
it(`combination #${index} works`, async () => { it(`combination #${index} works`, async () => {
const appConfig: AppConfig = { const appConfig: AppConfig = {
@ -338,7 +326,7 @@ describe('FrontendConfigService', () => {
const authConfig: AuthConfig = { const authConfig: AuthConfig = {
...emptyAuthConfig, ...emptyAuthConfig,
local: { local: {
enableLogin, enableLogin: true,
enableRegister, enableRegister,
}, },
}; };
@ -353,8 +341,7 @@ describe('FrontendConfigService', () => {
imprint: imprintLink, imprint: imprintLink,
}, },
}; };
const externalServicesConfig: ExternalServicesConfig = const externalServicesConfig: ExternalServicesConfig = {
{
plantUmlServer: plantUmlServer, plantUmlServer: plantUmlServer,
imageProxy: imageProxy, imageProxy: imageProxy,
}; };
@ -362,8 +349,7 @@ describe('FrontendConfigService', () => {
forbiddenNoteIds: [], forbiddenNoteIds: [],
maxDocumentLength: maxDocumentLength, maxDocumentLength: maxDocumentLength,
}; };
const module: TestingModule = const module: TestingModule = await Test.createTestingModule({
await Test.createTestingModule({
imports: [ imports: [
ConfigModule.forRoot({ ConfigModule.forRoot({
isGlobal: true, isGlobal: true,
@ -395,23 +381,17 @@ describe('FrontendConfigService', () => {
expect(config.branding.logo).toEqual( expect(config.branding.logo).toEqual(
customLogo ? new URL(customLogo) : undefined, customLogo ? new URL(customLogo) : undefined,
); );
expect( expect(config.iframeCommunication.editorOrigin).toEqual(
config.iframeCommunication.editorOrigin, new URL(appConfig.domain),
).toEqual(new URL(appConfig.domain)); );
expect( expect(config.iframeCommunication.rendererOrigin).toEqual(
config.iframeCommunication.rendererOrigin,
).toEqual(
appConfig.rendererOrigin appConfig.rendererOrigin
? new URL(appConfig.rendererOrigin) ? new URL(appConfig.rendererOrigin)
: new URL(appConfig.domain), : new URL(appConfig.domain),
); );
expect(config.maxDocumentLength).toEqual( expect(config.maxDocumentLength).toEqual(maxDocumentLength);
maxDocumentLength,
);
expect(config.plantUmlServer).toEqual( expect(config.plantUmlServer).toEqual(
plantUmlServer plantUmlServer ? new URL(plantUmlServer) : undefined,
? new URL(plantUmlServer)
: undefined,
); );
expect(config.specialUrls.imprint).toEqual( expect(config.specialUrls.imprint).toEqual(
imprintLink ? new URL(imprintLink) : undefined, imprintLink ? new URL(imprintLink) : undefined,
@ -420,9 +400,7 @@ describe('FrontendConfigService', () => {
privacyLink ? new URL(privacyLink) : undefined, privacyLink ? new URL(privacyLink) : undefined,
); );
expect(config.specialUrls.termsOfUse).toEqual( expect(config.specialUrls.termsOfUse).toEqual(
termsOfUseLink termsOfUseLink ? new URL(termsOfUseLink) : undefined,
? new URL(termsOfUseLink)
: undefined,
); );
expect(config.useImageProxy).toEqual(!!imageProxy); expect(config.useImageProxy).toEqual(!!imageProxy);
expect(config.version).toEqual( expect(config.version).toEqual(
@ -436,9 +414,4 @@ describe('FrontendConfigService', () => {
} }
} }
} }
}
}
}
}
}
}); });