diff --git a/packages/backend/src/graphql/queries/get-automatisch-info.test.ts b/packages/backend/src/graphql/queries/get-automatisch-info.test.ts index 0e72f2e8..bd06a2a7 100644 --- a/packages/backend/src/graphql/queries/get-automatisch-info.test.ts +++ b/packages/backend/src/graphql/queries/get-automatisch-info.test.ts @@ -1,7 +1,7 @@ -import { setMockConfig } from '../../../test/setup/set-mock-config'; import request from 'supertest'; import app from '../../app'; import * as license from '../../helpers/license.ee'; +import appConfig from '../../config/app'; describe('graphQL getAutomatischInfo query', () => { const query = ` @@ -21,6 +21,8 @@ describe('graphQL getAutomatischInfo query', () => { describe('and without valid license', () => { beforeEach(async () => { jest.spyOn(license, 'getLicense').mockResolvedValue(false); + + jest.replaceProperty(appConfig, 'isCloud', false) }); it('should return empty license data', async () => { @@ -61,7 +63,7 @@ describe('graphQL getAutomatischInfo query', () => { describe('and with cloud flag enabled', () => { beforeEach(async () => { - setMockConfig({ isCloud: true }); + jest.replaceProperty(appConfig, 'isCloud', true) }); it('should return all license data', async () => { @@ -90,7 +92,7 @@ describe('graphQL getAutomatischInfo query', () => { describe('and with cloud flag disabled', () => { beforeEach(async () => { - setMockConfig({ isCloud: false }); + jest.replaceProperty(appConfig, 'isCloud', false) }); it('should return all license data', async () => { diff --git a/packages/backend/src/graphql/queries/get-trial-status.ee.test.ts b/packages/backend/src/graphql/queries/get-trial-status.ee.test.ts index 285dcebd..703486a1 100644 --- a/packages/backend/src/graphql/queries/get-trial-status.ee.test.ts +++ b/packages/backend/src/graphql/queries/get-trial-status.ee.test.ts @@ -1,4 +1,3 @@ -import { setMockConfig } from '../../../test/setup/set-mock-config'; import request from 'supertest'; import app from '../../app'; import { IUser } from '@automatisch/types'; @@ -6,6 +5,7 @@ import User from '../../models/user'; import createUser from '../../../test/fixtures/user'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import { DateTime } from 'luxon'; +import appConfig from '../../config/app'; describe('graphQL getTrialStatus query', () => { const query = ` @@ -43,7 +43,7 @@ describe('graphQL getTrialStatus query', () => { describe('and with cloud flag disabled', () => { beforeEach(async () => { - setMockConfig({ isCloud: false }); + jest.replaceProperty(appConfig, 'isCloud', false); }); it('should return null', async () => { @@ -63,7 +63,7 @@ describe('graphQL getTrialStatus query', () => { describe('and with cloud flag enabled', () => { beforeEach(async () => { - setMockConfig({ isCloud: true }); + jest.replaceProperty(appConfig, 'isCloud', true); }); describe('and not in trial and has active subscription', () => { diff --git a/packages/backend/test/setup/global-hooks.ts b/packages/backend/test/setup/global-hooks.ts index 80d72630..e83f6204 100644 --- a/packages/backend/test/setup/global-hooks.ts +++ b/packages/backend/test/setup/global-hooks.ts @@ -1,16 +1,6 @@ import { Model } from 'objection'; import { client as knex } from '../../src/config/database'; import logger from '../../src/helpers/logger'; -import { mockConfigState, resetMockConfig } from './set-mock-config'; - -jest.mock('../../src/config/app', () => ({ - ...jest.requireActual('../../src/config/app').default, - get isCloud() { - return mockConfigState.isCloud !== undefined - ? mockConfigState.isCloud - : jest.requireActual('../../src/config/app').default.isCloud; - }, -})); global.beforeAll(async () => { global.knex = null; @@ -33,7 +23,6 @@ global.afterEach(async () => { Model.knex(knex); jest.clearAllMocks(); - resetMockConfig(); }); global.afterAll(async () => { diff --git a/packages/backend/test/setup/set-mock-config.ts b/packages/backend/test/setup/set-mock-config.ts deleted file mode 100644 index 954a93e3..00000000 --- a/packages/backend/test/setup/set-mock-config.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const mockConfigState = { - isCloud: false, -}; - -export const resetMockConfig = () => { - for (const key in mockConfigState) { - delete (mockConfigState as any)[key]; - } -}; - -export const setMockConfig = (config: Partial) => { - Object.assign(mockConfigState, config); -};