Skip to content

Commit 5906688

Browse files
committed
[Fix] 앱잼용 디바이스 토큰 삭제로 인한 check fail 해결
1 parent fc30ec6 commit 5906688

File tree

4 files changed

+9
-28
lines changed

4 files changed

+9
-28
lines changed

src/tests/getUser.test.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ GET /user
88

99
describe("[GET] /user", () => {
1010
const req = request(app);
11-
const fcm_token_ios = config.fcm_token_ios;
1211

1312
//200 OK - 유일 유저로
1413
it("유저 조회 테스트", async () => {
15-
const res = await req
16-
.get("/user/" + fcm_token_ios)
17-
.set("Content-Type", "application/json")
18-
.set("userId", "1");
14+
const res = await req.get("/user").set("Content-Type", "application/json").set("userId", "1");
1915
expect(res.status).toBe(200);
2016
expect(res.body.data).toEqual({
2117
nickname: "레코드림",
@@ -27,7 +23,7 @@ describe("[GET] /user", () => {
2723

2824
//400 Bad Request - userId 빼고 리퀘스트
2925
it("유저 조회 테스트(없는 id)", async () => {
30-
const res = await req.get("/user/" + fcm_token_ios).set("Content-Type", "application/json");
26+
const res = await req.get("/user").set("Content-Type", "application/json");
3127
expect(res.status).toBe(400);
3228
expect(res.body.message).toEqual("필요한 값이 없습니다.");
3329
});

src/tests/postNotice.test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ describe("[POST] /notice", () => {
1111
//201 CREATED - 푸시알림 시간 설정 성공
1212
it("푸시알림 시간 설정 테스트", async () => {
1313
const noticeData = {
14-
fcm_token: config.fcm_token_ios,
1514
time: "PM 05:55",
1615
};
1716

@@ -22,7 +21,6 @@ describe("[POST] /notice", () => {
2221
//400 Bad Request - 헤더에 userId 없음
2322
it("푸시알림 시간 설정 테스트(헤더에 userId 없음)", async () => {
2423
const noticeData = {
25-
fcm_token: config.fcm_token_ios,
2624
time: "PM 05:55",
2725
};
2826

@@ -34,7 +32,6 @@ describe("[POST] /notice", () => {
3432
//400 Bad Request - 해당 Fcm 토큰으로 이미 시간 설정을 한 경우
3533
it("푸시알림 시간 설정 테스트(해당 Fcm 토큰으로 이미 시간 설정 함)", async () => {
3634
const noticeData = {
37-
fcm_token: config.fcm_token_ios,
3835
time: "PM 05:55",
3936
};
4037

@@ -46,7 +43,6 @@ describe("[POST] /notice", () => {
4643
//404 Not Found - 헤더에 1 이외의 userId가 들어감
4744
it("푸시알림 시간 설정 테스트(헤더에 1 이외의 userId)", async () => {
4845
const noticeData = {
49-
fcm_token: config.fcm_token_ios,
5046
time: "PM 05:55",
5147
};
5248

src/tests/putNotice.test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ describe("[PUT] /user", () => {
1111
const originalTime = "PM 05:55";
1212

1313
let updateData = {
14-
fcm_token: config.fcm_token_ios,
1514
time: updateTime,
1615
};
1716
const originalData = {
18-
fcm_token: config.fcm_token_ios,
1917
time: originalTime,
2018
};
2119

@@ -42,7 +40,6 @@ describe("[PUT] /user", () => {
4240
it("푸시알림 시간 수정 테스트(time을 안 넣음)", async () => {
4341
updateTime = "";
4442
updateData = {
45-
fcm_token: config.fcm_token_ios,
4643
time: updateTime,
4744
};
4845
const res = await req.put("/notice").send(updateData).set("Content-Type", "application/json").set("userId", "1");

src/tests/putUser.test.ts

+7-15
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ PUT /user/:toggle
99
describe("[PUT] /user/nickname", () => {
1010
const req = request(app);
1111
let updateNickname = "레코더림1111";
12-
let originalNickname = "레코드림";
12+
const originalNickname = "레코드림";
1313
let updateData = {
1414
nickname: updateNickname,
1515
};
16-
let originalData = {
16+
const originalData = {
1717
nickname: originalNickname,
1818
};
1919

@@ -68,17 +68,10 @@ PUT /user/:toggle
6868
*/
6969
describe("[PUT] /user/:toggle", () => {
7070
const req = request(app);
71-
const fcm_token_ios = config.fcm_token_ios;
7271
let is_active = false;
73-
const tokenBody = {
74-
fcm_token: fcm_token_ios,
75-
};
7672

7773
beforeAll(async () => {
78-
const beforeAllRes = await req
79-
.get("/user/" + fcm_token_ios)
80-
.set("Content-Type", "application/json")
81-
.set("userId", "1");
74+
const beforeAllRes = await req.get("/user").set("Content-Type", "application/json").set("userId", "1");
8275
expect(beforeAllRes.status).toBe(200);
8376
is_active = beforeAllRes.body.data.is_active;
8477
});
@@ -90,22 +83,21 @@ describe("[PUT] /user/:toggle", () => {
9083
}
9184
const afterAllRes = await req
9285
.put("/user/" + toggle)
93-
.send(tokenBody)
9486
.set("Content-Type", "application/json")
9587
.set("userId", "1");
9688
expect(afterAllRes.status).toBe(200); //원래대로 돌려놓기
9789
});
9890

9991
//200 OK - 유일 유저로
10092
it("푸시알림 여부 수정 테스트(성공)", async () => {
101-
const res = await req.put("/user/0").send(tokenBody).set("Content-Type", "application/json").set("userId", "1");
93+
const res = await req.put("/user/0").set("Content-Type", "application/json").set("userId", "1");
10294
expect(res.status).toBe(200);
10395
expect(res.body.message).toEqual("푸시알림 여부 변경 성공");
10496
});
10597

10698
//400 Bad Request - userId 빼고 리퀘스트
10799
it("푸시알림 여부 수정 테스트(없는 id)", async () => {
108-
const res = await req.put("/user/1").send(tokenBody).set("Content-Type", "application/json");
100+
const res = await req.put("/user/1").set("Content-Type", "application/json");
109101
expect(res.status).toBe(400);
110102
expect(res.body.message).toEqual("필요한 값이 없습니다.");
111103
});
@@ -120,7 +112,7 @@ describe("[PUT] /user/:toggle", () => {
120112

121113
//404 Not Found - 헤더에 1 이외의 userId가 들어간 경우
122114
it("푸시알림 여부 수정 테스트(헤더에 1 이외의 userId가 들어간 경우)", async () => {
123-
const res = await req.put("/user/1").send(tokenBody).set("Content-Type", "application/json").set("userId", "2");
115+
const res = await req.put("/user/1").set("Content-Type", "application/json").set("userId", "2");
124116
expect(res.status).toBe(404);
125117
expect(res.body.message).toEqual("존재하지 않는 유저 또는 FCM 토큰");
126118
});
@@ -137,7 +129,7 @@ describe("[PUT] /user/:toggle", () => {
137129

138130
//404 Not Found (parameter 에 1 이나 0 이외의 값이 들어온 경우)
139131
it("푸시알림 여부 수정 테스트(parameter 에 1 이나 0 이외의 값이 들어온 경우)", async () => {
140-
const res = await req.put("/user/2").send(tokenBody).set("Content-Type", "application/json").set("userId", "1");
132+
const res = await req.put("/user/2").set("Content-Type", "application/json").set("userId", "1");
141133
expect(res.status).toBe(404);
142134
expect(res.body.message).toEqual("존재하지 않는 자원");
143135
});

0 commit comments

Comments
 (0)