Merge branch 'formatName' into 'main'

Format name

See merge request v3/service/user!49
This commit is contained in:
Sylvain Briat 2023-11-22 13:59:11 +00:00
commit ad8b98da40
4 changed files with 16 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@mobicoop/user", "name": "@mobicoop/user",
"version": "1.3.1", "version": "1.4.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@mobicoop/user", "name": "@mobicoop/user",
"version": "1.3.1", "version": "1.4.0",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.9.6", "@grpc/grpc-js": "^1.9.6",

View File

@ -1,6 +1,6 @@
{ {
"name": "@mobicoop/user", "name": "@mobicoop/user",
"version": "1.3.1", "version": "1.4.0",
"description": "Mobicoop V3 User Service", "description": "Mobicoop V3 User Service",
"author": "sbriat", "author": "sbriat",
"private": true, "private": true,

View File

@ -11,8 +11,8 @@ const now = new Date('2023-06-21 06:00:00');
const userEntity: UserEntity = new UserEntity({ const userEntity: UserEntity = new UserEntity({
id: 'c160cf8c-f057-4962-841f-3ad68346df44', id: 'c160cf8c-f057-4962-841f-3ad68346df44',
props: { props: {
firstName: 'John', firstName: 'john',
lastName: 'Doe', lastName: 'doe',
email: 'john.doe@email.com', email: 'john.doe@email.com',
phone: '+33611223344', phone: '+33611223344',
}, },
@ -45,7 +45,7 @@ describe('User Mapper', () => {
it('should map domain entity to persistence data', async () => { it('should map domain entity to persistence data', async () => {
const mapped: UserWriteModel = userMapper.toPersistence(userEntity); const mapped: UserWriteModel = userMapper.toPersistence(userEntity);
expect(mapped.lastName).toBe('Doe'); expect(mapped.lastName).toBe('doe');
}); });
it('should map persisted data to domain entity', async () => { it('should map persisted data to domain entity', async () => {

View File

@ -36,10 +36,16 @@ export class UserMapper
createdAt: new Date(record.createdAt), createdAt: new Date(record.createdAt),
updatedAt: new Date(record.updatedAt), updatedAt: new Date(record.updatedAt),
props: { props: {
firstName: record.firstName, firstName: `${record.firstName
lastName: record.lastName, ?.trim()
email: record.email, .charAt(0)
phone: record.phone, .toUpperCase()}${record.firstName?.trim().toLowerCase().slice(1)}`,
lastName: `${record.lastName
?.trim()
.charAt(0)
.toUpperCase()}${record.lastName?.trim().toLowerCase().slice(1)}`,
email: record.email?.trim().toLowerCase(),
phone: record.phone?.trim(),
}, },
}); });
return entity; return entity;