@@ -27,8 +27,6 @@ const wickhamToken = await wickham.getToken();
2727const lydiaToken = await lydia . getToken ( ) ;
2828const bingleyToken = await bingley . getToken ( ) ;
2929
30- //console.log("LIZ TOKEN ", elizabethToken);
31-
3230await elizabeth . sendFriendRequest ( darcy . email ) ;
3331await darcy . respondToFriendRequest ( elizabeth . email , "ACCEPTED" ) ;
3432await elizabeth . getPrivateChats ( elizabeth . email ) ;
@@ -40,19 +38,8 @@ await lydia.respondToFriendRequest(wickham.email, "ACCEPTED");
4038const createGroupURL = `${ process . env . BASE_URL } /chats/groups/create` ;
4139const addFriendToGroupURL = `${ process . env . BASE_URL } /chats/groups/add-friend` ;
4240
43- //let groupID;
44-
45- //
46-
4741describe ( "Group chats tests" , ( ) => {
4842 describe ( "Group Creation" , ( ) => {
49- // Cases =>
50- // 1. Elizabeth creates a group chat -> 200
51- // 2. Elizabeth tries to create a group with missing fields -> 400
52- // - groupName missing
53- // - groupDescription missing
54- // - adminEmail missing
55-
5643 it ( "Create a group chat -> 200" , async ( ) => {
5744 const res = await request ( app )
5845 . post ( createGroupURL )
@@ -62,7 +49,6 @@ describe("Group chats tests", () => {
6249 groupName : "Pride and Prejudice" ,
6350 groupDescription : "A group chat for discussing the novel" ,
6451 } ) ;
65- //groupID = res.body.body;
6652 expect ( res . status ) . toBe ( 200 ) ;
6753 } ) ;
6854
@@ -96,20 +82,10 @@ describe("Group chats tests", () => {
9682 } ) ;
9783
9884 describe ( "Add someone to group" , ( ) => {
99- // Cases =>
100- // 1. Elizabeth adds Darcy to the group -> 200
101- // 2. Elizabeth tries to add Darcy to the group with missing fields -> 400
102- // - groupID missing
103- // - friendEmail missing
104- // - adminEmail missing
105- // 3. Elizabeth tries to add Darcy to the group with wrong groupID non-existent group -> 400
106- // 4. Elizabeth tries to add Darcy to the group with wrong friendEmail -> 404
107- // 5. Wickham tries to add Darcy to the group -> 403
108-
10985 it ( "Add friend to group -> 200" , async ( ) => {
11086 const groupID = await elizabeth . createGroup (
11187 "Pride and Prejudice" ,
112- "A group chat for discussing the novel" ,
88+ "A group chat for discussing the novel"
11389 ) ;
11490
11591 const res = await request ( app )
@@ -120,14 +96,13 @@ describe("Group chats tests", () => {
12096 userEmail : darcy . email ,
12197 chatID : groupID ,
12298 } ) ;
123- //console.log("GROUP ID ", groupID);
12499 expect ( res . status ) . toBe ( 200 ) ;
125100 } ) ;
126101
127102 it ( "Add friend to group with missing fields -> 400" , async ( ) => {
128103 const groupID = await elizabeth . createGroup (
129104 "Pride and Prejudice" ,
130- "A group chat for discussing the novel" ,
105+ "A group chat for discussing the novel"
131106 ) ;
132107
133108 const possibleResponses = [
@@ -165,7 +140,7 @@ describe("Group chats tests", () => {
165140 it ( "Add friend to group with wrong groupID non-existent group -> 404" , async ( ) => {
166141 await elizabeth . createGroup (
167142 "Pride and Prejudice" ,
168- "A group chat for discussing the novel" ,
143+ "A group chat for discussing the novel"
169144 ) ;
170145 const groupID = "313233343536373839303132" ;
171146 const res = await request ( app )
@@ -182,7 +157,7 @@ describe("Group chats tests", () => {
182157 it ( "Add friend to group with wrong friendEmail -> 404" , async ( ) => {
183158 const groupID = await elizabeth . createGroup (
184159 "Pride and Prejudice" ,
185- "A group chat for discussing the novel" ,
160+ "A group chat for discussing the novel"
186161 ) ;
187162
188163 const res = await request ( app )
@@ -199,7 +174,7 @@ describe("Group chats tests", () => {
199174 it ( "User not in group trying to add another user, both are not friends -> 403" , async ( ) => {
200175 const groupID = await elizabeth . createGroup (
201176 "Pride and Prejudice" ,
202- "A group chat for discussing the novel" ,
177+ "A group chat for discussing the novel"
203178 ) ;
204179
205180 const res = await request ( app )
@@ -219,7 +194,7 @@ describe("Group chats tests", () => {
219194
220195 const groupID = await elizabeth . createGroup (
221196 "Pride and Prejudice" ,
222- "A group chat for discussing the novel" ,
197+ "A group chat for discussing the novel"
223198 ) ;
224199
225200 const res = await request ( app )
@@ -236,7 +211,7 @@ describe("Group chats tests", () => {
236211 it ( "User in group trying to add another user, both are not friends -> 403" , async ( ) => {
237212 const groupID = await elizabeth . createGroup (
238213 "Pride and Prejudice" ,
239- "A group chat for discussing the novel" ,
214+ "A group chat for discussing the novel"
240215 ) ;
241216
242217 await elizabeth . addFriendToGroup ( groupID , wickham . email ) ;
@@ -249,31 +224,20 @@ describe("Group chats tests", () => {
249224 userEmail : lydia . email ,
250225 chatID : groupID ,
251226 } ) ;
252- //console.log("USER ADD FRIEND TO GROUP ", res.body);
253227 expect ( res . status ) . toBe ( 403 ) ;
254228 } ) ;
255229 } ) ;
256230
257231 describe ( "Get group details" , ( ) => {
258- // Cases =>
259- // 1. Elizabeth, the admin, gets group details -> 200
260- // 2. Elizabeth tries to get group details with missing group ID -> 400
261- // 3. Elizabeth tries to get group details with wrong group ID format -> 400
262- // 4. Elizabeth tries to get group details for a non-existent group -> 404
263- // 5. Wickham, who isn't in the group, tries to get group details -> 403
264- // 6. Darcy, who is in the group, tries to get group details -> 200
265- //
266-
267232 it ( "Get group details -> 200" , async ( ) => {
268233 const groupID = await elizabeth . createGroup (
269234 "Pride and Prejudice" ,
270- "A group chat for discussing the novel" ,
235+ "A group chat for discussing the novel"
271236 ) ;
272237
273238 const res = await request ( app )
274239 . get ( `${ process . env . BASE_URL } /chats/groups/details/${ groupID } ` )
275240 . set ( "Authorization" , elizabethToken ) ;
276- //console.log("GROUP DETAILS ", res.body);
277241 expect ( res . status ) . toBe ( 200 ) ;
278242 } ) ;
279243
@@ -294,7 +258,7 @@ describe("Group chats tests", () => {
294258 it ( "Get group details for a non-existent group -> 404" , async ( ) => {
295259 const res = await request ( app )
296260 . get (
297- `${ process . env . BASE_URL } /chats/groups/details/313233343536373839303132` ,
261+ `${ process . env . BASE_URL } /chats/groups/details/313233343536373839303132`
298262 )
299263 . set ( "Authorization" , elizabethToken ) ;
300264 expect ( res . status ) . toBe ( 404 ) ;
@@ -303,7 +267,7 @@ describe("Group chats tests", () => {
303267 it ( "User not in group trying to get group details -> 403" , async ( ) => {
304268 const groupID = await elizabeth . createGroup (
305269 "Pride and Prejudice" ,
306- "A group chat for discussing the novel" ,
270+ "A group chat for discussing the novel"
307271 ) ;
308272
309273 const res = await request ( app )
@@ -315,10 +279,10 @@ describe("Group chats tests", () => {
315279 it ( "User in group trying to get group details -> 200" , async ( ) => {
316280 const groupID = await elizabeth . createGroup (
317281 "Pride and Prejudice" ,
318- "A group chat for discussing the novel" ,
282+ "A group chat for discussing the novel"
319283 ) ;
320284
321- const addDarcy = await elizabeth . addFriendToGroup ( groupID , darcy . email ) ;
285+ await elizabeth . addFriendToGroup ( groupID , darcy . email ) ;
322286
323287 const res = await request ( app )
324288 . get ( `${ process . env . BASE_URL } /chats/groups/details/${ groupID } ` )
@@ -328,19 +292,10 @@ describe("Group chats tests", () => {
328292 } ) ;
329293
330294 describe ( "Delete group" , ( ) => {
331- // Cases =>
332- // 1. Elizabeth, the admin, deletes the group -> 200
333- // 2. Elizabeth tries to delete the group with missing group ID -> 400
334- // 3. Elizabeth tries to delete the group with wrong group ID format -> 400
335- // 4. Elizabeth tries to delete a non-existent group -> 404
336- // 5. Elizabeth tries to delete the group, without passing admin email -> 400
337- // 5. Lydia, who isn't in the group, tries to delete the group -> 403
338- // 6. Darcy, who is in the group, tries to delete the group -> 403
339-
340295 it ( "Delete group -> 200" , async ( ) => {
341296 const groupID = await elizabeth . createGroup (
342297 "Pride and Prejudice" ,
343- "A group chat for discussing the novel" ,
298+ "A group chat for discussing the novel"
344299 ) ;
345300
346301 const res = await request ( app )
@@ -360,7 +315,6 @@ describe("Group chats tests", () => {
360315 . send ( {
361316 email : elizabeth . email ,
362317 } ) ;
363- //console.log("DELETE GROUP ", res.body);
364318 expect ( res . status ) . toBe ( 400 ) ;
365319 } ) ;
366320
@@ -387,7 +341,7 @@ describe("Group chats tests", () => {
387341 it ( "Delete group without passing admin email -> 400" , async ( ) => {
388342 const groupID = await elizabeth . createGroup (
389343 "Pride and Prejudice" ,
390- "A group chat for discussing the novel" ,
344+ "A group chat for discussing the novel"
391345 ) ;
392346
393347 const res = await request ( app )
@@ -402,7 +356,7 @@ describe("Group chats tests", () => {
402356 it ( "User not in group trying to delete group -> 403" , async ( ) => {
403357 const groupID = await elizabeth . createGroup (
404358 "Pride and Prejudice" ,
405- "A group chat for discussing the novel" ,
359+ "A group chat for discussing the novel"
406360 ) ;
407361
408362 const res = await request ( app )
@@ -417,7 +371,7 @@ describe("Group chats tests", () => {
417371 it ( "User in group trying to delete group -> 403" , async ( ) => {
418372 const groupID = await elizabeth . createGroup (
419373 "Pride and Prejudice" ,
420- "A group chat for discussing the novel" ,
374+ "A group chat for discussing the novel"
421375 ) ;
422376
423377 await elizabeth . addFriendToGroup ( groupID , darcy . email ) ;
0 commit comments