Skip to content

Commit 92f9030

Browse files
authored
Merge pull request #462 from boostcampwm-2024/refactor/test
✅ test: DTO 테스트 코드 일관성 및 독립성 향상
2 parents 55b66dd + c87cfde commit 92f9030

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2669
-1994
lines changed

server/package.json

Lines changed: 109 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,109 @@
1-
{
2-
"name": "denamu-was",
3-
"version": "0.0.1",
4-
"description": "",
5-
"author": "",
6-
"private": true,
7-
"license": "UNLICENSED",
8-
"scripts": {
9-
"build": "nest build",
10-
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11-
"start": "node dist/src/main.js",
12-
"start:dev": "nest start --watch",
13-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
14-
"test:unit": "cross-env NODE_ENV=TEST jest --config test/jest-unit.json",
15-
"test:unit:cov": "cross-env NODE_ENV=TEST jest --config test/jest-unit.json --coverage",
16-
"test:e2e": "cross-env NODE_ENV=TEST jest --config test/jest-e2e.json",
17-
"test:e2e:debug": "cross-env NODE_ENV=debug jest --config test/jest-e2e.json",
18-
"test:e2e:cov": "cross-env NODE_ENV=TEST jest --config test/jest-e2e.json --coverage",
19-
"test": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json",
20-
"test:watch": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json --watch",
21-
"test:cov": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json --coverage",
22-
"typeorm": "typeorm-ts-node-commonjs",
23-
"migration:create": "cross-env NODE_ENV=PROD npm run typeorm -- migration:create",
24-
"prod:migration:generate": "cross-env NODE_ENV=PROD npm run typeorm -- migration:generate -d dataSource.ts",
25-
"local:migration:generate": "cross-env NODE_ENV=LOCAL npm run typeorm -- migration:generate -d dataSource.ts"
26-
},
27-
"dependencies": {
28-
"@anthropic-ai/sdk": "^0.36.3",
29-
"@nestjs/axios": "^4.0.0",
30-
"@nestjs/common": "^10.0.0",
31-
"@nestjs/config": "^3.3.0",
32-
"@nestjs/core": "^10.0.0",
33-
"@nestjs/event-emitter": "^2.1.1",
34-
"@nestjs/jwt": "^11.0.0",
35-
"@nestjs/passport": "^11.0.5",
36-
"@nestjs/platform-express": "^10.0.0",
37-
"@nestjs/platform-socket.io": "^10.4.8",
38-
"@nestjs/schedule": "^4.1.1",
39-
"@nestjs/swagger": "^8.0.1",
40-
"@nestjs/typeorm": "^10.0.2",
41-
"@nestjs/websockets": "^10.4.8",
42-
"@willsoto/nestjs-prometheus": "^6.0.2",
43-
"@woowa-babble/random-nickname": "^1.0.2",
44-
"axios": "^1.8.4",
45-
"bcrypt": "^5.1.1",
46-
"class-transformer": "^0.5.1",
47-
"class-validator": "^0.14.1",
48-
"cookie-parser": "^1.4.7",
49-
"cross-env": "^7.0.3",
50-
"fast-xml-parser": "^4.5.1",
51-
"html-escaper": "^3.0.3",
52-
"ioredis": "^5.4.1",
53-
"lodash": "^4.17.21",
54-
"mysql2": "^3.11.3",
55-
"nest-winston": "^1.9.7",
56-
"node-cron": "^3.0.3",
57-
"node-html-parser": "^7.0.1",
58-
"nodemailer": "^6.9.16",
59-
"passport-jwt": "^4.0.1",
60-
"prom-client": "^15.1.3",
61-
"reflect-metadata": "^0.2.0",
62-
"rxjs": "^7.8.1",
63-
"sanitize-html": "^2.14.0",
64-
"typeorm": "^0.3.20",
65-
"uuid": "^11.1.0",
66-
"winston": "^3.16.0",
67-
"winston-daily-rotate-file": "^5.0.0"
68-
},
69-
"devDependencies": {
70-
"@nestjs/cli": "^11.0.10",
71-
"@nestjs/schematics": "^10.0.0",
72-
"@nestjs/testing": "^10.0.0",
73-
"@testcontainers/mysql": "^10.16.0",
74-
"@testcontainers/redis": "^10.16.0",
75-
"@types/bcrypt": "^5.0.2",
76-
"@types/cookie-parser": "^1.4.7",
77-
"@types/eventsource": "^1.1.15",
78-
"@types/express": "^5.0.0",
79-
"@types/jest": "^29.5.2",
80-
"@types/lodash": "^4.17.13",
81-
"@types/node": "^20.3.1",
82-
"@types/nodemailer": "^6.4.16",
83-
"@types/passport-jwt": "^4.0.1",
84-
"@types/sanitize-html": "^2.13.0",
85-
"@types/supertest": "^6.0.0",
86-
"@types/uuid": "^10.0.0",
87-
"@typescript-eslint/eslint-plugin": "^8.0.0",
88-
"@typescript-eslint/parser": "^8.0.0",
89-
"eslint": "^9.0.0",
90-
"eslint-config-prettier": "^9.0.0",
91-
"eslint-plugin-prettier": "^5.0.0",
92-
"eventsource": "^2.0.2",
93-
"ioredis-mock": "^8.9.0",
94-
"jest": "^29.5.0",
95-
"prettier": "^3.0.0",
96-
"source-map-support": "^0.5.21",
97-
"supertest": "^7.0.0",
98-
"testcontainers": "^10.16.0",
99-
"ts-jest": "^29.1.0",
100-
"ts-loader": "^9.4.3",
101-
"ts-node": "^10.9.1",
102-
"tsconfig-paths": "^4.2.0",
103-
"typescript": "^5.1.3"
104-
}
105-
}
1+
{
2+
"name": "denamu-was",
3+
"version": "0.0.1",
4+
"description": "",
5+
"author": "",
6+
"private": true,
7+
"license": "UNLICENSED",
8+
"scripts": {
9+
"build": "nest build",
10+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11+
"start": "node dist/src/main.js",
12+
"start:dev": "nest start --watch",
13+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
14+
"test:unit": "cross-env NODE_ENV=TEST jest --config test/jest-unit.json",
15+
"test:unit:cov": "cross-env NODE_ENV=TEST jest --config test/jest-unit.json --coverage",
16+
"test:unit:watch": "cross-env NODE_ENV=TEST jest --config test/jest-unit.json --watch",
17+
"test:e2e": "cross-env NODE_ENV=TEST jest --config test/jest-e2e.json",
18+
"test:e2e:cov": "cross-env NODE_ENV=TEST jest --config test/jest-e2e.json --coverage",
19+
"test:e2e:watch": "cross-env NODE_ENV=TEST jest --config test/jest-e2e.json --watch",
20+
"test:dto": "cross-env NODE_ENV=TEST jest --config test/jest-dto.json",
21+
"test:dto:cov": "cross-env NODE_ENV=TEST jest --config test/jest-dto.json --coverage",
22+
"test:dto:watch": "cross-env NODE_ENV=TEST jest --config test/jest-dto.json --watch",
23+
"test": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json",
24+
"test:cov": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json --coverage",
25+
"test:watch": "cross-env NODE_ENV=TEST jest --config test/jest-integration.json --watch",
26+
"typeorm": "typeorm-ts-node-commonjs",
27+
"migration:create": "cross-env NODE_ENV=PROD npm run typeorm -- migration:create",
28+
"prod:migration:generate": "cross-env NODE_ENV=PROD npm run typeorm -- migration:generate -d dataSource.ts",
29+
"local:migration:generate": "cross-env NODE_ENV=LOCAL npm run typeorm -- migration:generate -d dataSource.ts"
30+
},
31+
"dependencies": {
32+
"@anthropic-ai/sdk": "^0.36.3",
33+
"@nestjs/axios": "^4.0.0",
34+
"@nestjs/common": "^10.0.0",
35+
"@nestjs/config": "^3.3.0",
36+
"@nestjs/core": "^10.0.0",
37+
"@nestjs/event-emitter": "^2.1.1",
38+
"@nestjs/jwt": "^11.0.0",
39+
"@nestjs/passport": "^11.0.5",
40+
"@nestjs/platform-express": "^10.0.0",
41+
"@nestjs/platform-socket.io": "^10.4.8",
42+
"@nestjs/schedule": "^4.1.1",
43+
"@nestjs/swagger": "^8.0.1",
44+
"@nestjs/typeorm": "^10.0.2",
45+
"@nestjs/websockets": "^10.4.8",
46+
"@willsoto/nestjs-prometheus": "^6.0.2",
47+
"@woowa-babble/random-nickname": "^1.0.2",
48+
"axios": "^1.8.4",
49+
"bcrypt": "^5.1.1",
50+
"class-transformer": "^0.5.1",
51+
"class-validator": "^0.14.1",
52+
"cookie-parser": "^1.4.7",
53+
"cross-env": "^7.0.3",
54+
"fast-xml-parser": "^4.5.1",
55+
"html-escaper": "^3.0.3",
56+
"ioredis": "^5.4.1",
57+
"lodash": "^4.17.21",
58+
"mysql2": "^3.11.3",
59+
"nest-winston": "^1.9.7",
60+
"node-cron": "^3.0.3",
61+
"node-html-parser": "^7.0.1",
62+
"nodemailer": "^6.9.16",
63+
"passport-jwt": "^4.0.1",
64+
"prom-client": "^15.1.3",
65+
"reflect-metadata": "^0.2.0",
66+
"rxjs": "^7.8.1",
67+
"sanitize-html": "^2.14.0",
68+
"typeorm": "^0.3.20",
69+
"uuid": "^11.1.0",
70+
"winston": "^3.16.0",
71+
"winston-daily-rotate-file": "^5.0.0"
72+
},
73+
"devDependencies": {
74+
"@nestjs/cli": "^11.0.10",
75+
"@nestjs/schematics": "^10.0.0",
76+
"@nestjs/testing": "^10.0.0",
77+
"@testcontainers/mysql": "^10.16.0",
78+
"@testcontainers/redis": "^10.16.0",
79+
"@types/bcrypt": "^5.0.2",
80+
"@types/cookie-parser": "^1.4.7",
81+
"@types/eventsource": "^1.1.15",
82+
"@types/express": "^5.0.0",
83+
"@types/jest": "^29.5.2",
84+
"@types/lodash": "^4.17.13",
85+
"@types/node": "^20.3.1",
86+
"@types/nodemailer": "^6.4.16",
87+
"@types/passport-jwt": "^4.0.1",
88+
"@types/sanitize-html": "^2.13.0",
89+
"@types/supertest": "^6.0.0",
90+
"@types/uuid": "^10.0.0",
91+
"@typescript-eslint/eslint-plugin": "^8.0.0",
92+
"@typescript-eslint/parser": "^8.0.0",
93+
"eslint": "^9.0.0",
94+
"eslint-config-prettier": "^9.0.0",
95+
"eslint-plugin-prettier": "^5.0.0",
96+
"eventsource": "^2.0.2",
97+
"ioredis-mock": "^8.9.0",
98+
"jest": "^29.5.0",
99+
"prettier": "^3.0.0",
100+
"source-map-support": "^0.5.21",
101+
"supertest": "^7.0.0",
102+
"testcontainers": "^10.16.0",
103+
"ts-jest": "^29.1.0",
104+
"ts-loader": "^9.4.3",
105+
"ts-node": "^10.9.1",
106+
"tsconfig-paths": "^4.2.0",
107+
"typescript": "^5.1.3"
108+
}
109+
}
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+
}

0 commit comments

Comments
 (0)