@@ -64,6 +64,7 @@ describe("Discord actions", function () {
64
64
let discordId = "" ;
65
65
let fetchStub ;
66
66
let jwt ;
67
+
67
68
beforeEach ( async function ( ) {
68
69
fetchStub = sinon . stub ( global , "fetch" ) ;
69
70
userId = await addUser ( userData [ 0 ] ) ;
@@ -106,6 +107,7 @@ describe("Discord actions", function () {
106
107
return done ( ) ;
107
108
} ) ;
108
109
} ) ;
110
+
109
111
it ( "Should throw error if failed to update a picture" , function ( done ) {
110
112
fetchStub . returns (
111
113
Promise . resolve ( {
@@ -132,6 +134,7 @@ describe("Discord actions", function () {
132
134
describe ( "GET /discord-actions/groups" , function ( ) {
133
135
let newGroupData ;
134
136
let allIds = [ ] ;
137
+
135
138
before ( async function ( ) {
136
139
const addUsersPromises = userData . map ( ( user ) => userModel . add ( { ...user } ) ) ;
137
140
const responses = await Promise . all ( addUsersPromises ) ;
@@ -209,6 +212,7 @@ describe("Discord actions", function () {
209
212
210
213
describe ( "POST /discord-actions/roles" , function ( ) {
211
214
let roleid ;
215
+
212
216
beforeEach ( async function ( ) {
213
217
const discordRoleModelPromise = [
214
218
discordRoleModel . add ( groupData [ 0 ] ) ,
@@ -224,6 +228,7 @@ describe("Discord actions", function () {
224
228
sinon . restore ( ) ;
225
229
await cleanDb ( ) ;
226
230
} ) ;
231
+
227
232
it ( "should not be able to add role if it is not a group type role" , async function ( ) {
228
233
const fetchStub = sinon . stub ( discordRolesModel , "isGroupRoleExists" ) ;
229
234
@@ -257,6 +262,7 @@ describe("Discord actions", function () {
257
262
258
263
fetchStub . restore ( ) ;
259
264
} ) ;
265
+
260
266
it ( "should allow role to be added" , async function ( ) {
261
267
fetchStub . returns (
262
268
Promise . resolve ( {
@@ -275,6 +281,7 @@ describe("Discord actions", function () {
275
281
expect ( res . body ) . to . be . an ( "object" ) ;
276
282
expect ( res . body . message ) . to . equal ( "Role added successfully!" ) ;
277
283
} ) ;
284
+
278
285
it ( "should create a reason and pass it down to the bot, on adding the role to the user" , async function ( ) {
279
286
fetchStub . returns (
280
287
Promise . resolve ( {
@@ -298,6 +305,7 @@ describe("Discord actions", function () {
298
305
`Action initiator's username=>ankur and id=${ userId } `
299
306
) ;
300
307
} ) ;
308
+
301
309
it ( "should not allow unknown role to be added to user" , async function ( ) {
302
310
const res = await chai
303
311
. request ( app )
@@ -309,6 +317,7 @@ describe("Discord actions", function () {
309
317
expect ( res . body ) . to . be . an ( "object" ) ;
310
318
expect ( res . body . message ) . to . equal ( "Permission denied. Cannot add the role." ) ;
311
319
} ) ;
320
+
312
321
it ( "should not allow role to be added when userid does not belong to authenticated user" , async function ( ) {
313
322
const res = await chai
314
323
. request ( app )
@@ -321,6 +330,7 @@ describe("Discord actions", function () {
321
330
expect ( res . body . message ) . to . equal ( "Permission denied. Cannot add the role." ) ;
322
331
} ) ;
323
332
} ) ;
333
+
324
334
describe ( "DELETE /discord-actions/roles" , function ( ) {
325
335
let roleid ;
326
336
@@ -385,6 +395,7 @@ describe("Discord actions", function () {
385
395
`Action initiator's username=>ankur and id=${ userId } `
386
396
) ;
387
397
} ) ;
398
+
388
399
it ( "should not allow unknown role to be deleted from user" , async function ( ) {
389
400
const res = await chai
390
401
. request ( app )
@@ -396,6 +407,7 @@ describe("Discord actions", function () {
396
407
expect ( res . body ) . to . be . an ( "object" ) ;
397
408
expect ( res . body . message ) . to . equal ( "Permission denied. Cannot delete the role." ) ;
398
409
} ) ;
410
+
399
411
it ( "should not allow role to be deleted when userid does not belong to authenticated user" , async function ( ) {
400
412
const res = await chai
401
413
. request ( app )
@@ -407,6 +419,7 @@ describe("Discord actions", function () {
407
419
expect ( res . body ) . to . be . an ( "object" ) ;
408
420
expect ( res . body . message ) . to . equal ( "Permission denied. Cannot delete the role." ) ;
409
421
} ) ;
422
+
410
423
it ( "should handle internal server error" , function ( done ) {
411
424
chai
412
425
. request ( app )
@@ -472,6 +485,7 @@ describe("Discord actions", function () {
472
485
473
486
describe ( "POST /discord-actions/nickname/status" , function ( ) {
474
487
let jwtToken ;
488
+
475
489
beforeEach ( async function ( ) {
476
490
const userData2 = { ...userData [ 1 ] } ;
477
491
delete userData2 . discordId ;
@@ -562,6 +576,7 @@ describe("Discord actions", function () {
562
576
} ) ;
563
577
} ) . timeout ( 10000 ) ;
564
578
} ) ;
579
+
565
580
describe ( "POST /discord-actions/discord-roles" , function ( ) {
566
581
before ( async function ( ) {
567
582
const value = [ discordRoleModel . add ( groupData [ 0 ] ) , discordRoleModel . add ( groupData [ 1 ] ) ] ;
@@ -596,6 +611,7 @@ describe("Discord actions", function () {
596
611
597
612
describe ( "PUT /discord-actions/group-idle-7d" , function ( ) {
598
613
let allIds ;
614
+
599
615
beforeEach ( async function ( ) {
600
616
userData [ 0 ] . roles = { archived : false } ;
601
617
userData [ 1 ] . roles = { archived : false } ;
@@ -695,6 +711,7 @@ describe("Discord actions", function () {
695
711
} )
696
712
) ;
697
713
} ) ;
714
+
698
715
afterEach ( async function ( ) {
699
716
sinon . restore ( ) ;
700
717
await cleanDb ( ) ;
0 commit comments