Skip to content

Commit 470067f

Browse files
committed
✅ test: 누락 테스트 작성 및 검증 추가
1 parent 7f9761d commit 470067f

30 files changed

+835
-358
lines changed
Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,52 @@
1-
import { IsString, Length, Matches } from 'class-validator';
2-
import { ApiProperty } from '@nestjs/swagger';
3-
import { Admin } from '../../entity/admin.entity';
4-
5-
const PASSWORD_REG = /^(?=.*[!@#$%^&*()_+])[A-Za-z0-9!@#$%^&*()_+]+$/;
6-
7-
export class RegisterAdminRequestDto {
8-
@ApiProperty({
9-
example: 'test',
10-
description: '관리자 로그인 아이디를 입력해주세요.',
11-
})
12-
@IsString({
13-
message: '문자열을 입력해주세요',
14-
})
15-
@Length(6, 255, {
16-
message: '아이디의 길이는 6자 이상, 255자 이하로 작성해주세요.',
17-
})
18-
loginId: string;
19-
20-
@ApiProperty({
21-
example: 'test1234!',
22-
description:
23-
'패스워드를 입력해주세요. (최소 6자, 영문/숫자/특수문자로 이루어질 수 있으며 특수문자 1개 이상 포함)',
24-
})
25-
@IsString({
26-
message: '문자열을 입력해주세요',
27-
})
28-
@Matches(PASSWORD_REG, {
29-
message:
30-
'영문, 숫자, 특수문자로 이루어질 수 있으며 특수문자는 1개 이상 포함해주세요.',
31-
})
32-
@Length(6, 60, {
33-
message: '패스워드의 길이는 6자 이상, 60자 이하로 작성해주세요.',
34-
})
35-
password: string;
36-
37-
constructor(partial: Partial<RegisterAdminRequestDto>) {
38-
Object.assign(this, partial);
39-
}
40-
41-
toEntity() {
42-
const admin = new Admin();
43-
Object.assign(admin, this);
44-
return admin;
45-
}
46-
}
1+
import { IsNotEmpty, IsString, Length, Matches } from 'class-validator';
2+
import { ApiProperty } from '@nestjs/swagger';
3+
import { Admin } from '../../entity/admin.entity';
4+
5+
const PASSWORD_REG = /^(?=.*[!@#$%^&*()_+])[A-Za-z0-9!@#$%^&*()_+]+$/;
6+
7+
export class RegisterAdminRequestDto {
8+
@ApiProperty({
9+
example: 'test',
10+
description: '관리자 로그인 아이디를 입력해주세요.',
11+
})
12+
@IsNotEmpty({
13+
message: '아이디가 없습니다.',
14+
})
15+
@IsString({
16+
message: '문자열을 입력해주세요',
17+
})
18+
@Length(6, 255, {
19+
message: '아이디의 길이는 6자 이상, 255자 이하로 작성해주세요.',
20+
})
21+
loginId: string;
22+
23+
@ApiProperty({
24+
example: 'test1234!',
25+
description:
26+
'패스워드를 입력해주세요. (최소 6자, 영문/숫자/특수문자로 이루어질 수 있으며 특수문자 1개 이상 포함)',
27+
})
28+
@IsNotEmpty({
29+
message: '비밀번호가 없습니다.',
30+
})
31+
@IsString({
32+
message: '문자열을 입력해주세요',
33+
})
34+
@Matches(PASSWORD_REG, {
35+
message:
36+
'영문, 숫자, 특수문자로 이루어질 수 있으며 특수문자는 1개 이상 포함해주세요.',
37+
})
38+
@Length(6, 60, {
39+
message: '패스워드의 길이는 6자 이상, 60자 이하로 작성해주세요.',
40+
})
41+
password: string;
42+
43+
constructor(partial: Partial<RegisterAdminRequestDto>) {
44+
Object.assign(this, partial);
45+
}
46+
47+
toEntity() {
48+
const admin = new Admin();
49+
Object.assign(admin, this);
50+
return admin;
51+
}
52+
}
Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
import { IsDefined, IsEnum, IsInt, IsString, Min } from 'class-validator';
2-
import { Type } from 'class-transformer';
3-
import { ApiProperty } from '@nestjs/swagger';
4-
5-
export enum SearchType {
6-
TITLE = 'title',
7-
BLOGNAME = 'blogName',
8-
ALL = 'all',
9-
}
10-
11-
export class SearchFeedRequestDto {
12-
@ApiProperty({
13-
example: 'example',
14-
description: '검색어 입력',
15-
})
16-
@IsDefined({
17-
message: '검색어를 입력해주세요.',
18-
})
19-
@IsString({
20-
message: '문자열로 입력해주세요.',
21-
})
22-
find: string;
23-
24-
@ApiProperty({
25-
example: 'example',
26-
description: '검색 타입 입력',
27-
enum: ['title', 'blogName', 'all'],
28-
})
29-
@IsDefined({
30-
message: '검색 타입을 입력해주세요.',
31-
})
32-
@IsEnum(SearchType, {
33-
message: '검색 타입은 title, blogName, all 중 하나여야 합니다.',
34-
})
35-
type: SearchType;
36-
37-
@ApiProperty({
38-
example: 1,
39-
description: '페이지 번호 입력',
40-
})
41-
@IsInt({
42-
message: '페이지 번호는 정수입니다.',
43-
})
44-
@Min(1, { message: '페이지 번호는 1 이상이어야 합니다.' })
45-
@Type(() => Number)
46-
page?: number = 1;
47-
48-
@ApiProperty({
49-
example: 1,
50-
description: '받아올 게시글 최대 개수',
51-
})
52-
@IsInt({
53-
message: '한 페이지에 보여줄 개수는 정수입니다.',
54-
})
55-
@Min(1, { message: '개수 제한은 1 이상이어야 합니다.' })
56-
@Type(() => Number)
57-
limit?: number = 4;
58-
59-
constructor(partial: Partial<SearchFeedRequestDto>) {
60-
Object.assign(this, partial);
61-
}
62-
}
1+
import { IsNotEmpty, IsEnum, IsInt, IsString, Min } from 'class-validator';
2+
import { Type } from 'class-transformer';
3+
import { ApiProperty } from '@nestjs/swagger';
4+
5+
export enum SearchType {
6+
TITLE = 'title',
7+
BLOGNAME = 'blogName',
8+
ALL = 'all',
9+
}
10+
11+
export class SearchFeedRequestDto {
12+
@ApiProperty({
13+
example: 'example',
14+
description: '검색어 입력',
15+
})
16+
@IsNotEmpty({
17+
message: '검색어를 입력해주세요.',
18+
})
19+
@IsString({
20+
message: '문자열로 입력해주세요.',
21+
})
22+
find: string;
23+
24+
@ApiProperty({
25+
example: 'example',
26+
description: '검색 타입 입력',
27+
enum: ['title', 'blogName', 'all'],
28+
})
29+
@IsNotEmpty({
30+
message: '검색 타입을 입력해주세요.',
31+
})
32+
@IsEnum(SearchType, {
33+
message: '검색 타입은 title, blogName, all 중 하나여야 합니다.',
34+
})
35+
type: SearchType;
36+
37+
@ApiProperty({
38+
example: 1,
39+
description: '페이지 번호 입력',
40+
})
41+
@IsInt({
42+
message: '페이지 번호는 정수입니다.',
43+
})
44+
@Min(1, { message: '페이지 번호는 1 이상이어야 합니다.' })
45+
@Type(() => Number)
46+
page?: number = 1;
47+
48+
@ApiProperty({
49+
example: 1,
50+
description: '받아올 게시글 최대 개수',
51+
})
52+
@IsInt({
53+
message: '한 페이지에 보여줄 개수는 정수입니다.',
54+
})
55+
@Min(1, { message: '개수 제한은 1 이상이어야 합니다.' })
56+
@Type(() => Number)
57+
limit?: number = 4;
58+
59+
constructor(partial: Partial<SearchFeedRequestDto>) {
60+
Object.assign(this, partial);
61+
}
62+
}
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { ApiProperty } from '@nestjs/swagger';
2-
import { FileUploadType } from '../../../common/disk/fileValidator';
3-
4-
export class UploadFileQueryDto {
5-
@ApiProperty({
6-
description: '파일 업로드 타입',
7-
enum: FileUploadType,
8-
example: FileUploadType.PROFILE_IMAGE,
9-
required: false,
10-
})
11-
uploadType: FileUploadType;
12-
}
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { FileUploadType } from '../../../common/disk/fileValidator';
3+
4+
export class UploadFileQueryDto {
5+
@ApiProperty({
6+
description: '파일 업로드 타입',
7+
enum: FileUploadType,
8+
example: FileUploadType.PROFILE_IMAGE,
9+
required: false,
10+
})
11+
uploadType: FileUploadType;
12+
13+
constructor(partial: Partial<UploadFileQueryDto>) {
14+
Object.assign(this, partial);
15+
}
16+
}
Lines changed: 70 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,70 @@
1-
import { ApiProperty } from '@nestjs/swagger';
2-
import { IsEmail, IsNotEmpty, IsString, IsUrl, Length } from 'class-validator';
3-
import { Rss } from '../../entity/rss.entity';
4-
5-
export class RegisterRssRequestDto {
6-
@ApiProperty({
7-
example: 'seok3765.log',
8-
description: '블로그 이름을 입력해주세요.',
9-
})
10-
@IsString({
11-
message: '문자열로 입력해주세요.',
12-
})
13-
@IsNotEmpty({
14-
message: '블로그 이름이 없습니다.',
15-
})
16-
blog: string;
17-
18-
@ApiProperty({
19-
example: 'test',
20-
description: '실명을 입력해주세요.',
21-
})
22-
@Length(2, 50, { message: '이름 길이가 올바르지 않습니다.' })
23-
@IsString({
24-
message: '문자열로 입력해주세요.',
25-
})
26-
@IsNotEmpty({
27-
message: '실명이 없습니다.',
28-
})
29-
name: string;
30-
31-
@ApiProperty({
32-
example: '[email protected]',
33-
description: '이메일을 입력해주세요.',
34-
})
35-
@IsEmail(
36-
{},
37-
{
38-
message: '이메일 주소 형식에 맞춰서 작성해주세요.',
39-
},
40-
)
41-
@IsNotEmpty({
42-
message: '이메일이 없습니다.',
43-
})
44-
email: string;
45-
46-
@ApiProperty({
47-
example: 'https://test.com/rss',
48-
description: 'RSS 주소를 입력해주세요.',
49-
})
50-
@IsUrl(
51-
{
52-
require_protocol: true,
53-
protocols: ['http', 'https'],
54-
},
55-
{
56-
message: 'http, https 프로토콜과 URL 형식을 맞춰주세요.',
57-
},
58-
)
59-
@IsNotEmpty({
60-
message: 'RSS URL이 없습니다.',
61-
})
62-
rssUrl: string;
63-
64-
constructor(partial: Partial<RegisterRssRequestDto>) {
65-
Object.assign(this, partial);
66-
}
67-
68-
toEntity() {
69-
const rss = new Rss();
70-
rss.name = this.blog;
71-
rss.userName = this.name;
72-
rss.email = this.email;
73-
rss.rssUrl = this.rssUrl;
74-
return rss;
75-
}
76-
}
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsEmail, IsNotEmpty, IsString, IsUrl, Length } from 'class-validator';
3+
import { Rss } from '../../entity/rss.entity';
4+
5+
export class RegisterRssRequestDto {
6+
@ApiProperty({
7+
example: 'seok3765.log',
8+
description: '블로그 이름을 입력해주세요.',
9+
})
10+
@IsString({
11+
message: '문자열로 입력해주세요.',
12+
})
13+
@IsNotEmpty({
14+
message: '블로그 이름이 없습니다.',
15+
})
16+
blog: string;
17+
18+
@ApiProperty({
19+
example: 'test',
20+
description: '실명을 입력해주세요.',
21+
})
22+
@Length(2, 50, { message: '이름 길이가 올바르지 않습니다.' })
23+
@IsString({
24+
message: '문자열로 입력해주세요.',
25+
})
26+
@IsNotEmpty({
27+
message: '실명이 없습니다.',
28+
})
29+
name: string;
30+
31+
@ApiProperty({
32+
example: '[email protected]',
33+
description: '이메일을 입력해주세요.',
34+
})
35+
@IsEmail(
36+
{},
37+
{
38+
message: '이메일 주소 형식에 맞춰서 작성해주세요.',
39+
},
40+
)
41+
email: string;
42+
43+
@ApiProperty({
44+
example: 'https://test.com/rss',
45+
description: 'RSS 주소를 입력해주세요.',
46+
})
47+
@IsUrl(
48+
{
49+
require_protocol: true,
50+
protocols: ['http', 'https'],
51+
},
52+
{
53+
message: 'http, https 프로토콜과 URL 형식을 맞춰주세요.',
54+
},
55+
)
56+
rssUrl: string;
57+
58+
constructor(partial: Partial<RegisterRssRequestDto>) {
59+
Object.assign(this, partial);
60+
}
61+
62+
toEntity() {
63+
const rss = new Rss();
64+
rss.name = this.blog;
65+
rss.userName = this.name;
66+
rss.email = this.email;
67+
rss.rssUrl = this.rssUrl;
68+
return rss;
69+
}
70+
}

0 commit comments

Comments
 (0)