From c1e438210dfb4b089194dda71a3038222314f177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=95=EB=85=84?= <64246800+KangNyeonKim@users.noreply.github.com> Date: Mon, 12 Dec 2022 23:30:23 +0900 Subject: [PATCH] =?UTF-8?q?style:=20=EC=BD=94=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/User/User.Test.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/src/User/User.Test.ts b/server/src/User/User.Test.ts index d03bde1..b6bf07b 100644 --- a/server/src/User/User.Test.ts +++ b/server/src/User/User.Test.ts @@ -8,7 +8,16 @@ import app from "../app"; dotenv.config(); -beforeAll(async () => { +const testUser = { + name: "testUser", + id: 58, + infAccessToken: + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTgsImlhdCI6MTY3MDgyODE2MH0.vQrK4E6RbQfPxpTt0cjBmhYVtlihWJelKSdssm2W45E", + infRefreshToken: + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTgsImlhdCI6MTY3MDgyODE2NH0.07bukMgpAcfDik8Umlg2UtTvVKmWFotf3AHy_legMWs", +}; + +const testUserRefreshToken = beforeAll(async () => { const myDataSource = new DataSource({ type: "mysql", host: process.env.TYPEORM_HOST || "", @@ -25,19 +34,13 @@ beforeAll(async () => { // 본인 유저 정보 describe("GET api/users", () => { - const testUserName = "testUser"; - const testUserId = 58; - const testUserAccessToken = - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTgsImlhdCI6MTY3MDgyODE2MH0.vQrK4E6RbQfPxpTt0cjBmhYVtlihWJelKSdssm2W45E"; - const testUserRefreshToken = - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTgsImlhdCI6MTY3MDgyODE2NH0.07bukMgpAcfDik8Umlg2UtTvVKmWFotf3AHy_legMWs"; test("로그인한 유저의 경우 유저 정보 반환", (done) => { request(app) .get("/api/users") - .set("Cookie", [`accessToken=${testUserAccessToken}`, `refreshToken=${testUserRefreshToken}`]) + .set("Cookie", [`accessToken=${testUser.infAccessToken}`, `refreshToken=${testUser.infRefreshToken}`]) .expect(200) .then((res) => { - expect(res.body).toEqual({ userID: testUserId, userName: testUserName }); + expect(res.body).toEqual({ userID: testUser.id, userName: testUser.name }); done(); }) .catch((err) => {