From 4d529e5823e842a4cb7eb8e15a982add65acec1d Mon Sep 17 00:00:00 2001 From: MajedAlaitwniCap Date: Fri, 13 Dec 2024 17:15:06 +0100 Subject: [PATCH] fix no implicit public part3 --- .../modules/account/domain/update-account.ts | 6 +++--- .../account/domain/update-my-account.ts | 10 +++++----- .../account.repo.integration.spec.ts | 20 +++++++++++++++++++ .../mapper/account-entity-to-do.mapper.ts | 6 +++--- .../account-idm-to-do.mapper.abstract.ts | 2 +- .../mapper/account-idm-to-do.mapper.db.ts | 2 +- .../mapper/account-idm-to-do.mapper.idm.ts | 2 +- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/apps/server/src/modules/account/domain/update-account.ts b/apps/server/src/modules/account/domain/update-account.ts index 8dde8829eee..48a8e41a80d 100644 --- a/apps/server/src/modules/account/domain/update-account.ts +++ b/apps/server/src/modules/account/domain/update-account.ts @@ -1,9 +1,9 @@ export class UpdateAccount { - username?: string; + public username?: string; - password?: string; + public password?: string; - activated?: boolean; + public activated?: boolean; constructor(props: UpdateAccount) { this.username = props.username; diff --git a/apps/server/src/modules/account/domain/update-my-account.ts b/apps/server/src/modules/account/domain/update-my-account.ts index 433b7338cff..90a8606fee7 100644 --- a/apps/server/src/modules/account/domain/update-my-account.ts +++ b/apps/server/src/modules/account/domain/update-my-account.ts @@ -1,13 +1,13 @@ export class UpdateMyAccount { - passwordOld!: string; + public passwordOld!: string; - passwordNew?: string; + public passwordNew?: string; - email?: string; + public email?: string; - firstName?: string; + public firstName?: string; - lastName?: string; + public lastName?: string; constructor(props: UpdateMyAccount) { this.passwordOld = props.passwordOld; diff --git a/apps/server/src/modules/account/repo/micro-orm/account.repo.integration.spec.ts b/apps/server/src/modules/account/repo/micro-orm/account.repo.integration.spec.ts index 76aff5bad1a..9a76454061e 100644 --- a/apps/server/src/modules/account/repo/micro-orm/account.repo.integration.spec.ts +++ b/apps/server/src/modules/account/repo/micro-orm/account.repo.integration.spec.ts @@ -36,6 +36,26 @@ describe('account repo', () => { expect(repo.entityName).toBe(AccountEntity); }); + describe('mapDOToEntityProperties', () => { + describe('When an account is given', () => { + it('should map the account to an entity', () => { + const account = accountDoFactory.build(); + const entityProps = AccountDoToEntityMapper.mapToEntity(account); + + expect(entityProps).toEqual(expect.objectContaining(account.getProps())); + }); + }); + + describe('When an account with partial props is given', () => { + it('should map the account to an entity', () => { + const account = accountDoFactory.build({ id: new ObjectId().toHexString(), username: 'John Doe' }); + const entityProps = AccountDoToEntityMapper.mapToEntity(account); + + expect(entityProps).toEqual(expect.objectContaining(account.getProps())); + }); + }); + }); + describe('save', () => { describe('When an account is given', () => { it('should save an account', async () => { diff --git a/apps/server/src/modules/account/repo/micro-orm/mapper/account-entity-to-do.mapper.ts b/apps/server/src/modules/account/repo/micro-orm/mapper/account-entity-to-do.mapper.ts index 000ece5001a..221bdf7a147 100644 --- a/apps/server/src/modules/account/repo/micro-orm/mapper/account-entity-to-do.mapper.ts +++ b/apps/server/src/modules/account/repo/micro-orm/mapper/account-entity-to-do.mapper.ts @@ -3,7 +3,7 @@ import { Account } from '../../../domain/account'; import { AccountEntity } from '../../../domain/entity/account.entity'; export class AccountEntityToDoMapper { - static mapToDo(account: AccountEntity): Account { + public static mapToDo(account: AccountEntity): Account { return new Account({ id: account.id, createdAt: account.createdAt, @@ -22,13 +22,13 @@ export class AccountEntityToDoMapper { }); } - static mapCountedEntities(accountEntities: Counted): Counted { + public static mapCountedEntities(accountEntities: Counted): Counted { const foundAccounts = accountEntities[0]; const accountDtos: Account[] = AccountEntityToDoMapper.mapEntitiesToDos(foundAccounts); return [accountDtos, accountEntities[1]]; } - static mapEntitiesToDos(accounts: AccountEntity[]): Account[] { + public static mapEntitiesToDos(accounts: AccountEntity[]): Account[] { return accounts.map((accountEntity) => AccountEntityToDoMapper.mapToDo(accountEntity)); } } diff --git a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.abstract.ts b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.abstract.ts index 955e2b42da6..034a6c63107 100644 --- a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.abstract.ts +++ b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.abstract.ts @@ -4,5 +4,5 @@ import { Account } from '../../../domain/account'; @Injectable() export abstract class AccountIdmToDoMapper { - abstract mapToDo(account: IdmAccount): Account; + public abstract mapToDo(account: IdmAccount): Account; } diff --git a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.db.ts b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.db.ts index 1d8b0be686d..8dc47c32fd8 100644 --- a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.db.ts +++ b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.db.ts @@ -3,7 +3,7 @@ import { Account } from '../../../domain/account'; import { AccountIdmToDoMapper } from './account-idm-to-do.mapper.abstract'; export class AccountIdmToDoMapperDb extends AccountIdmToDoMapper { - mapToDo(account: IdmAccount): Account { + public mapToDo(account: IdmAccount): Account { const createdDate = account.createdDate ? account.createdDate : new Date(); return new Account({ id: account.attDbcAccountId ?? '', diff --git a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.idm.ts b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.idm.ts index b5402ed58a2..9f96d653480 100644 --- a/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.idm.ts +++ b/apps/server/src/modules/account/repo/micro-orm/mapper/account-idm-to-do.mapper.idm.ts @@ -3,7 +3,7 @@ import { Account } from '../../../domain/account'; import { AccountIdmToDoMapper } from './account-idm-to-do.mapper.abstract'; export class AccountIdmToDoMapperIdm extends AccountIdmToDoMapper { - mapToDo(account: IdmAccount): Account { + public mapToDo(account: IdmAccount): Account { const createdDate = account.createdDate ? account.createdDate : new Date(); return new Account({ id: account.id,