pr feedback

This commit is contained in:
martabal 2023-11-13 17:00:29 +01:00
parent ac9e2cd316
commit 0ed5dc869a
No known key found for this signature in database
GPG key ID: C00196E3148A52BD
3 changed files with 10 additions and 4 deletions

View file

@ -38,7 +38,14 @@ export const mapSimpleUser = (entity: UserEntity): UserDto => {
email: entity.email,
name: entity.name,
profileImagePath: entity.profileImagePath,
avatarColor: entity.avatarColor ?? getRandomAvatarColor(entity.email.length),
avatarColor:
entity.avatarColor ??
getRandomAvatarColor(
entity.email
.split('')
.map((letter) => letter.charCodeAt(0))
.reduce((a, b) => a + b, 0),
),
};
};

View file

@ -310,7 +310,6 @@ describe(UserService.name, () => {
expect(userMock.getAdmin).toBeCalled();
expect(userMock.create).toBeCalledWith({
avatarColor: expect.anything(),
email: userStub.user1.email,
name: userStub.user1.name,
storageLabel: 'label',

View file

@ -1,4 +1,4 @@
import { UserDtoAvatarColorEnum, type UserResponseDto } from '@api';
import { UserAvatarColor, type UserResponseDto } from '@api';
import { faker } from '@faker-js/faker';
import { Sync } from 'factory.ts';
@ -16,5 +16,5 @@ export const userFactory = Sync.makeFactory<UserResponseDto>({
updatedAt: Sync.each(() => faker.date.past().toISOString()),
memoriesEnabled: true,
oauthId: '',
avatarColor: UserDtoAvatarColorEnum.Primary,
avatarColor: UserAvatarColor.Primary,
});