refactor: remove additional mock implentation in tests

This commit is contained in:
Ali BARIN
2023-10-19 13:41:12 +02:00
parent 59770c80db
commit aead014bcf
4 changed files with 8 additions and 30 deletions

View File

@@ -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 () => {

View File

@@ -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<typeof mockConfigState>) => {
Object.assign(mockConfigState, config);
};