Skip to content

Commit eb3b8f0

Browse files
committed
✅ test: 검증 값 문자열 일관화
1 parent 7c5a95b commit eb3b8f0

14 files changed

+77
-129
lines changed

server/test/comment/dto/createComment.dto.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('CreateCommentRequestDto Test', () => {
2828
const errors = await validate(dto);
2929

3030
// then
31-
expect(errors).not.toHaveLength(0);
31+
expect(errors).toHaveLength(1);
3232
expect(errors[0].constraints).toHaveProperty('isNotEmpty');
3333
});
3434

@@ -40,7 +40,7 @@ describe('CreateCommentRequestDto Test', () => {
4040
const errors = await validate(dto);
4141

4242
// then
43-
expect(errors).not.toHaveLength(0);
43+
expect(errors).toHaveLength(1);
4444
expect(errors[0].constraints).toHaveProperty('isString');
4545
});
4646
});
@@ -54,7 +54,7 @@ describe('CreateCommentRequestDto Test', () => {
5454
const errors = await validate(dto);
5555

5656
// then
57-
expect(errors).not.toHaveLength(0);
57+
expect(errors).toHaveLength(1);
5858
expect(errors[0].constraints).toHaveProperty('isInt');
5959
});
6060

@@ -66,7 +66,7 @@ describe('CreateCommentRequestDto Test', () => {
6666
const errors = await validate(dto);
6767

6868
// then
69-
expect(errors).not.toHaveLength(0);
69+
expect(errors).toHaveLength(1);
7070
expect(errors[0].constraints).toHaveProperty('isInt');
7171
});
7272
});

server/test/comment/dto/deleteComment.dto.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('DeleteCommentRequestDto Test', () => {
2727
const errors = await validate(dto);
2828

2929
// then
30-
expect(errors).not.toHaveLength(0);
30+
expect(errors).toHaveLength(1);
3131
expect(errors[0].constraints).toHaveProperty('isInt');
3232
});
3333

@@ -39,7 +39,7 @@ describe('DeleteCommentRequestDto Test', () => {
3939
const errors = await validate(dto);
4040

4141
// then
42-
expect(errors).not.toHaveLength(0);
42+
expect(errors).toHaveLength(1);
4343
expect(errors[0].constraints).toHaveProperty('isInt');
4444
});
4545

@@ -51,7 +51,7 @@ describe('DeleteCommentRequestDto Test', () => {
5151
const errors = await validate(dto);
5252

5353
// then
54-
expect(errors).not.toHaveLength(0);
54+
expect(errors).toHaveLength(1);
5555
expect(errors[0].constraints).toHaveProperty('isInt');
5656
});
5757
});

server/test/comment/dto/getComment.dto.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('GetCommentRequestDto Test', () => {
2727
const errors = await validate(dto);
2828

2929
// then
30-
expect(errors).not.toHaveLength(0);
30+
expect(errors).toHaveLength(1);
3131
expect(errors[0].constraints).toHaveProperty('isInt');
3232
});
3333

@@ -39,7 +39,7 @@ describe('GetCommentRequestDto Test', () => {
3939
const errors = await validate(dto);
4040

4141
// then
42-
expect(errors).not.toHaveLength(0);
42+
expect(errors).toHaveLength(1);
4343
expect(errors[0].constraints).toHaveProperty('isInt');
4444
});
4545

@@ -51,7 +51,7 @@ describe('GetCommentRequestDto Test', () => {
5151
const errors = await validate(dto);
5252

5353
// then
54-
expect(errors).not.toHaveLength(0);
54+
expect(errors).toHaveLength(1);
5555
expect(errors[0].constraints).toHaveProperty('isInt');
5656
});
5757
});

server/test/comment/dto/updateComment.dto.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('UpdateCommentRequestDto Test', () => {
2828
const errors = await validate(dto);
2929

3030
// then
31-
expect(errors).not.toHaveLength(0);
31+
expect(errors).toHaveLength(1);
3232
expect(errors[0].constraints).toHaveProperty('isNotEmpty');
3333
});
3434

@@ -40,7 +40,7 @@ describe('UpdateCommentRequestDto Test', () => {
4040
const errors = await validate(dto);
4141

4242
// then
43-
expect(errors).not.toHaveLength(0);
43+
expect(errors).toHaveLength(1);
4444
expect(errors[0].constraints).toHaveProperty('isString');
4545
});
4646
});
@@ -54,7 +54,7 @@ describe('UpdateCommentRequestDto Test', () => {
5454
const errors = await validate(dto);
5555

5656
// then
57-
expect(errors).not.toHaveLength(0);
57+
expect(errors).toHaveLength(1);
5858
expect(errors[0].constraints).toHaveProperty('isInt');
5959
});
6060

@@ -66,7 +66,7 @@ describe('UpdateCommentRequestDto Test', () => {
6666
const errors = await validate(dto);
6767

6868
// then
69-
expect(errors).not.toHaveLength(0);
69+
expect(errors).toHaveLength(1);
7070
expect(errors[0].constraints).toHaveProperty('isInt');
7171
});
7272

@@ -78,7 +78,7 @@ describe('UpdateCommentRequestDto Test', () => {
7878
const errors = await validate(dto);
7979

8080
// then
81-
expect(errors).not.toHaveLength(0);
81+
expect(errors).toHaveLength(1);
8282
expect(errors[0].constraints).toHaveProperty('isInt');
8383
});
8484
});

server/test/rss/dto/deleteCertificateRss.dto.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ describe('DeleteCertificateRssRequestDto Test', () => {
2727
const errors = await validate(dto);
2828

2929
// then
30-
expect(errors[0].constraints).toHaveProperty(
31-
'isString',
32-
'문자열로 입력해주세요.',
33-
);
30+
expect(errors).toHaveLength(1);
31+
expect(errors[0].constraints).toHaveProperty('isString');
3432
});
3533

3634
it('인증 코드가 없다.', async () => {
@@ -41,10 +39,8 @@ describe('DeleteCertificateRssRequestDto Test', () => {
4139
const errors = await validate(dto);
4240

4341
// then
44-
expect(errors[0].constraints).toHaveProperty(
45-
'isNotEmpty',
46-
'인증 코드를 입력해주세요.',
47-
);
42+
expect(errors).toHaveLength(1);
43+
expect(errors[0].constraints).toHaveProperty('isNotEmpty');
4844
});
4945
});
5046
});

server/test/rss/dto/deleteRss.dto.spec.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ describe('DeleteRssRequestDto Test', () => {
2828
const errors = await validate(dto);
2929

3030
// then
31-
expect(errors[0].constraints).toHaveProperty(
32-
'isUrl',
33-
'유효한 URL을 입력해주세요.',
34-
);
31+
expect(errors).toHaveLength(1);
32+
expect(errors[0].constraints).toHaveProperty('isUrl');
3533
});
3634

3735
it('블로그 주소가 올바르지 않다.', async () => {
@@ -42,10 +40,8 @@ describe('DeleteRssRequestDto Test', () => {
4240
const errors = await validate(dto);
4341

4442
// then
45-
expect(errors[0].constraints).toHaveProperty(
46-
'isUrl',
47-
'유효한 URL을 입력해주세요.',
48-
);
43+
expect(errors).toHaveLength(1);
44+
expect(errors[0].constraints).toHaveProperty('isUrl');
4945
});
5046
});
5147

@@ -58,10 +54,8 @@ describe('DeleteRssRequestDto Test', () => {
5854
const errors = await validate(dto);
5955

6056
// then
61-
expect(errors[0].constraints).toHaveProperty(
62-
'isEmail',
63-
'올바른 이메일 주소를 입력하세요.',
64-
);
57+
expect(errors).toHaveLength(1);
58+
expect(errors[0].constraints).toHaveProperty('isEmail');
6559
});
6660

6761
it('이메일 주소가 올바르지 않다.', async () => {
@@ -72,10 +66,8 @@ describe('DeleteRssRequestDto Test', () => {
7266
const errors = await validate(dto);
7367

7468
// then
75-
expect(errors[0].constraints).toHaveProperty(
76-
'isEmail',
77-
'올바른 이메일 주소를 입력하세요.',
78-
);
69+
expect(errors).toHaveLength(1);
70+
expect(errors[0].constraints).toHaveProperty('isEmail');
7971
});
8072
});
8173
});

server/test/rss/dto/manageRss.dto.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ describe('ManageRssRequestDto Test', () => {
2727
const errors = await validate(dto);
2828

2929
// then
30-
expect(errors.length).toBe(1);
31-
expect(errors[0].constraints).toHaveProperty(
32-
'isInt',
33-
'정수를 입력해주세요.',
34-
);
30+
expect(errors).toHaveLength(1);
31+
expect(errors[0].constraints).toHaveProperty('isInt');
3532
});
3633
});
3734
});

0 commit comments

Comments
 (0)