refactor: remove additional mock implentation in tests
This commit is contained in:
@@ -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 () => {
|
||||
|
@@ -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);
|
||||
};
|
Reference in New Issue
Block a user