-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from LocalMingle/dev
Eric -> dev -> main
- Loading branch information
Showing
8 changed files
with
207 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,32 +6,43 @@ import { | |
Matches, | ||
MaxLength, | ||
MinLength, | ||
IsOptional, | ||
} from 'class-validator'; | ||
|
||
export class UpdateUserDto { | ||
@IsString() | ||
@IsNotEmpty() | ||
@MinLength(2) | ||
@MaxLength(8) | ||
//영어 또는 한글이 포함 | ||
@Matches(/^(?=.*[A-Za-z가-힣]).*[A-Za-z가-힣0-9]*$/) | ||
@IsOptional() | ||
@ApiProperty({ | ||
description: 'nickname', | ||
example: '닉네임', | ||
}) | ||
nickname: string; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@ApiProperty({ | ||
description: 'intro', | ||
example: '안녕하세요', | ||
}) | ||
intro: string; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@ApiProperty({ | ||
description: 'email', | ||
example: '[email protected]', | ||
}) | ||
email: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
@MinLength(8) | ||
@MaxLength(15) | ||
@IsOptional() | ||
//알파벳 포함 , 숫자 포함 , 특수문자 포함 | ||
@Matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]+$/) | ||
@ApiProperty({ | ||
|
@@ -42,6 +53,7 @@ export class UpdateUserDto { | |
|
||
@IsString() | ||
@IsNotEmpty() | ||
@IsOptional() | ||
@ApiProperty({ | ||
description: 'password confirm', | ||
example: 'abc123456789!', | ||
|
@@ -53,4 +65,12 @@ export class UpdateUserDto { | |
example: false, | ||
}) | ||
nameChanged: boolean; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@ApiProperty({ | ||
description: 'userLocation', | ||
example: '서울시 강남구', | ||
}) | ||
userLocation?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// src/users/dto/update-user.dto.ts | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class UpdateUserPasswordDto { | ||
@ApiProperty({ | ||
example: '1234', // 예시 값을 설정 | ||
description: 'The password of the user for password update', | ||
}) | ||
password: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,56 @@ | |
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { UsersController } from './users.controller'; | ||
import { UsersService } from './users.service'; | ||
// import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { UsersModule } from './users.module'; | ||
import { PrismaService } from '../prisma/prisma.service'; | ||
import { AwsS3Service } from '../aws/aws.s3'; | ||
|
||
describe('UsersController unit test', () => { | ||
// let app: INestApplication; | ||
let controller: UsersController; | ||
let service: UsersService; | ||
|
||
// const userServiceTest = { findAll: () => ['test1', 'test2'] }; | ||
// console.log('userServiceTest:', userServiceTest); | ||
|
||
let requestMock = {}; | ||
let responseMock = {}; | ||
const mockPrismaService = { | ||
// 여기에 필요한 메서드를 mock 구현 | ||
}; | ||
|
||
const mockUsersService = { | ||
findOne: jest.fn((id: number) => { | ||
return { userId: id, email: '[email protected]' }; | ||
}), | ||
}; | ||
|
||
beforeAll(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [UsersController], | ||
imports: [UsersModule], | ||
providers: [UsersService], | ||
}) | ||
// .overrideProvider(UsersService) | ||
// .useValue(userServiceTest) | ||
.compile(); | ||
providers: [ | ||
{ provide: UsersService, useValue: mockUsersService }, | ||
{ provide: PrismaService, useValue: mockPrismaService }, | ||
AwsS3Service, | ||
], | ||
}).compile(); | ||
|
||
controller = module.get<UsersController>(UsersController); | ||
// app = module.createNestApplication(); | ||
// await app.init(); | ||
service = module.get<UsersService>(UsersService); | ||
}); | ||
|
||
// jest test | ||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
// it('should be defined', () => { | ||
// expect(controller).toBeDefined(); | ||
// }); | ||
|
||
describe('Unit Tests', () => { | ||
// TC01: findOne(id: number) 테스트 | ||
it('TC01: findOne should return a user object', async () => { | ||
const id = '1'; | ||
expect(await controller.findOne(id)).toEqual({ | ||
userId: 1, | ||
email: '[email protected]', | ||
}); | ||
expect(service.findOne).toHaveBeenCalledWith(id); | ||
}); | ||
}); | ||
|
||
describe('Unit Tests', () => { | ||
|
Oops, something went wrong.