refactor(core): Make controller constructors consistent (no-changelog) (#7015)

This commit is contained in:
Iván Ovejero
2023-08-25 13:23:22 +02:00
committed by GitHub
parent 07d3633a05
commit 87cf1d9c1b
10 changed files with 145 additions and 270 deletions

View File

@@ -9,20 +9,14 @@ import { AUTH_COOKIE_NAME } from '@/constants';
import { BadRequestError } from '@/ResponseHelper';
import type { AuthenticatedRequest, MeRequest } from '@/requests';
import { badPasswords } from '../shared/testData';
import { UserService } from '@/services/user.service';
import Container from 'typedi';
import type { UserService } from '@/services/user.service';
describe('MeController', () => {
const logger = mock<ILogger>();
const externalHooks = mock<IExternalHooksClass>();
const internalHooks = mock<IInternalHooksClass>();
const userService = mock<UserService>();
Container.set(UserService, userService);
const controller = new MeController({
logger,
externalHooks,
internalHooks,
});
const controller = new MeController(logger, externalHooks, internalHooks, userService);
describe('updateCurrentUser', () => {
it('should throw BadRequestError if email is missing in the payload', async () => {

View File

@@ -12,7 +12,6 @@ import { OwnerController } from '@/controllers';
import { badPasswords } from '../shared/testData';
import { AUTH_COOKIE_NAME } from '@/constants';
import { UserService } from '@/services/user.service';
import Container from 'typedi';
import { mockInstance } from '../../integration/shared/utils';
describe('OwnerController', () => {
@@ -20,16 +19,14 @@ describe('OwnerController', () => {
const logger = mock<ILogger>();
const internalHooks = mock<IInternalHooksClass>();
const userService = mockInstance(UserService);
Container.set(UserService, userService);
const settingsRepository = mock<SettingsRepository>();
const controller = new OwnerController({
const controller = new OwnerController(
config,
logger,
internalHooks,
repositories: {
Settings: settingsRepository,
},
});
settingsRepository,
userService,
);
describe('setupOwner', () => {
it('should throw a BadRequestError if the instance owner is already setup', async () => {