@@ -9,11 +9,11 @@ PUT /user/:toggle
9
9
describe ( "[PUT] /user/nickname" , ( ) => {
10
10
const req = request ( app ) ;
11
11
let updateNickname = "레코더림1111" ;
12
- let originalNickname = "레코드림" ;
12
+ const originalNickname = "레코드림" ;
13
13
let updateData = {
14
14
nickname : updateNickname ,
15
15
} ;
16
- let originalData = {
16
+ const originalData = {
17
17
nickname : originalNickname ,
18
18
} ;
19
19
@@ -68,17 +68,10 @@ PUT /user/:toggle
68
68
*/
69
69
describe ( "[PUT] /user/:toggle" , ( ) => {
70
70
const req = request ( app ) ;
71
- const fcm_token_ios = config . fcm_token_ios ;
72
71
let is_active = false ;
73
- const tokenBody = {
74
- fcm_token : fcm_token_ios ,
75
- } ;
76
72
77
73
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" ) ;
82
75
expect ( beforeAllRes . status ) . toBe ( 200 ) ;
83
76
is_active = beforeAllRes . body . data . is_active ;
84
77
} ) ;
@@ -90,22 +83,21 @@ describe("[PUT] /user/:toggle", () => {
90
83
}
91
84
const afterAllRes = await req
92
85
. put ( "/user/" + toggle )
93
- . send ( tokenBody )
94
86
. set ( "Content-Type" , "application/json" )
95
87
. set ( "userId" , "1" ) ;
96
88
expect ( afterAllRes . status ) . toBe ( 200 ) ; //원래대로 돌려놓기
97
89
} ) ;
98
90
99
91
//200 OK - 유일 유저로
100
92
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" ) ;
102
94
expect ( res . status ) . toBe ( 200 ) ;
103
95
expect ( res . body . message ) . toEqual ( "푸시알림 여부 변경 성공" ) ;
104
96
} ) ;
105
97
106
98
//400 Bad Request - userId 빼고 리퀘스트
107
99
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" ) ;
109
101
expect ( res . status ) . toBe ( 400 ) ;
110
102
expect ( res . body . message ) . toEqual ( "필요한 값이 없습니다." ) ;
111
103
} ) ;
@@ -120,7 +112,7 @@ describe("[PUT] /user/:toggle", () => {
120
112
121
113
//404 Not Found - 헤더에 1 이외의 userId가 들어간 경우
122
114
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" ) ;
124
116
expect ( res . status ) . toBe ( 404 ) ;
125
117
expect ( res . body . message ) . toEqual ( "존재하지 않는 유저 또는 FCM 토큰" ) ;
126
118
} ) ;
@@ -137,7 +129,7 @@ describe("[PUT] /user/:toggle", () => {
137
129
138
130
//404 Not Found (parameter 에 1 이나 0 이외의 값이 들어온 경우)
139
131
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" ) ;
141
133
expect ( res . status ) . toBe ( 404 ) ;
142
134
expect ( res . body . message ) . toEqual ( "존재하지 않는 자원" ) ;
143
135
} ) ;
0 commit comments