fix: replace first and last name with single field (#4915)

This commit is contained in:
Brian Austin
2023-11-11 20:03:32 -05:00
committed by GitHub
parent 413ab2c538
commit 7fca0d8da5
98 changed files with 567 additions and 1147 deletions
@@ -7,8 +7,7 @@ describe('create user DTO', () => {
const params: Partial<CreateUserDto> = {
email: undefined,
password: 'password',
firstName: 'first name',
lastName: 'last name',
name: 'name',
};
let dto: CreateUserDto = plainToInstance(CreateUserDto, params);
let errors = await validate(dto);
@@ -31,8 +30,7 @@ describe('create user DTO', () => {
const dto = plainToInstance(CreateUserDto, {
email: someEmail,
password: 'some password',
firstName: 'some first name',
lastName: 'some last name',
name: 'some name',
});
const errors = await validate(dto);
expect(errors).toHaveLength(0);
@@ -48,8 +46,7 @@ describe('create admin DTO', () => {
isAdmin: true,
email: someEmail,
password: 'some password',
firstName: 'some first name',
lastName: 'some last name',
name: 'some name',
});
const errors = await validate(dto);
expect(errors).toHaveLength(0);
@@ -64,8 +61,7 @@ describe('create user oauth DTO', () => {
const dto = plainToInstance(CreateUserOAuthDto, {
email: someEmail,
oauthId: 'some oauth id',
firstName: 'some first name',
lastName: 'some last name',
name: 'some name',
});
const errors = await validate(dto);
expect(errors).toHaveLength(0);
+3 -12
View File
@@ -13,11 +13,7 @@ export class CreateUserDto {
@IsNotEmpty()
@IsString()
firstName!: string;
@IsNotEmpty()
@IsString()
lastName!: string;
name!: string;
@Optional({ nullable: true })
@IsString()
@@ -45,10 +41,7 @@ export class CreateAdminDto {
password!: string;
@IsNotEmpty()
firstName!: string;
@IsNotEmpty()
lastName!: string;
name!: string;
}
export class CreateUserOAuthDto {
@@ -59,7 +52,5 @@ export class CreateUserOAuthDto {
@IsNotEmpty()
oauthId!: string;
firstName?: string;
lastName?: string;
name?: string;
}
@@ -17,12 +17,7 @@ export class UpdateUserDto {
@Optional()
@IsString()
@IsNotEmpty()
firstName?: string;
@Optional()
@IsString()
@IsNotEmpty()
lastName?: string;
name?: string;
@Optional()
@IsString()
@@ -2,8 +2,7 @@ import { UserEntity } from '@app/infra/entities';
export class UserDto {
id!: string;
firstName!: string;
lastName!: string;
name!: string;
email!: string;
profileImagePath!: string;
}
@@ -24,8 +23,7 @@ export const mapSimpleUser = (entity: UserEntity): UserDto => {
return {
id: entity.id,
email: entity.email,
firstName: entity.firstName,
lastName: entity.lastName,
name: entity.name,
profileImagePath: entity.profileImagePath,
};
};
+3 -6
View File
@@ -289,8 +289,7 @@ describe(UserService.name, () => {
await expect(
sut.create({
email: 'john_smith@email.com',
firstName: 'John',
lastName: 'Smith',
name: 'John Smith',
password: 'password',
}),
).rejects.toBeInstanceOf(BadRequestException);
@@ -303,8 +302,7 @@ describe(UserService.name, () => {
await expect(
sut.create({
email: userStub.user1.email,
firstName: userStub.user1.firstName,
lastName: userStub.user1.lastName,
name: userStub.user1.name,
password: 'password',
storageLabel: 'label',
}),
@@ -313,8 +311,7 @@ describe(UserService.name, () => {
expect(userMock.getAdmin).toBeCalled();
expect(userMock.create).toBeCalledWith({
email: userStub.user1.email,
firstName: userStub.user1.firstName,
lastName: userStub.user1.lastName,
name: userStub.user1.name,
storageLabel: 'label',
password: expect.anything(),
});