@@ -64,6 +64,7 @@ describe("Discord actions", function () {
6464 let discordId = "" ;
6565 let fetchStub ;
6666 let jwt ;
67+
6768 beforeEach ( async function ( ) {
6869 fetchStub = sinon . stub ( global , "fetch" ) ;
6970 userId = await addUser ( userData [ 0 ] ) ;
@@ -106,6 +107,7 @@ describe("Discord actions", function () {
106107 return done ( ) ;
107108 } ) ;
108109 } ) ;
110+
109111 it ( "Should throw error if failed to update a picture" , function ( done ) {
110112 fetchStub . returns (
111113 Promise . resolve ( {
@@ -132,6 +134,7 @@ describe("Discord actions", function () {
132134 describe ( "GET /discord-actions/groups" , function ( ) {
133135 let newGroupData ;
134136 let allIds = [ ] ;
137+
135138 before ( async function ( ) {
136139 const addUsersPromises = userData . map ( ( user ) => userModel . add ( { ...user } ) ) ;
137140 const responses = await Promise . all ( addUsersPromises ) ;
@@ -209,6 +212,7 @@ describe("Discord actions", function () {
209212
210213 describe ( "POST /discord-actions/roles" , function ( ) {
211214 let roleid ;
215+
212216 beforeEach ( async function ( ) {
213217 const discordRoleModelPromise = [
214218 discordRoleModel . add ( groupData [ 0 ] ) ,
@@ -224,6 +228,7 @@ describe("Discord actions", function () {
224228 sinon . restore ( ) ;
225229 await cleanDb ( ) ;
226230 } ) ;
231+
227232 it ( "should not be able to add role if it is not a group type role" , async function ( ) {
228233 const fetchStub = sinon . stub ( discordRolesModel , "isGroupRoleExists" ) ;
229234
@@ -257,6 +262,7 @@ describe("Discord actions", function () {
257262
258263 fetchStub . restore ( ) ;
259264 } ) ;
265+
260266 it ( "should allow role to be added" , async function ( ) {
261267 fetchStub . returns (
262268 Promise . resolve ( {
@@ -275,6 +281,7 @@ describe("Discord actions", function () {
275281 expect ( res . body ) . to . be . an ( "object" ) ;
276282 expect ( res . body . message ) . to . equal ( "Role added successfully!" ) ;
277283 } ) ;
284+
278285 it ( "should create a reason and pass it down to the bot, on adding the role to the user" , async function ( ) {
279286 fetchStub . returns (
280287 Promise . resolve ( {
@@ -298,6 +305,7 @@ describe("Discord actions", function () {
298305 `Action initiator's username=>ankur and id=${ userId } `
299306 ) ;
300307 } ) ;
308+
301309 it ( "should not allow unknown role to be added to user" , async function ( ) {
302310 const res = await chai
303311 . request ( app )
@@ -309,6 +317,7 @@ describe("Discord actions", function () {
309317 expect ( res . body ) . to . be . an ( "object" ) ;
310318 expect ( res . body . message ) . to . equal ( "Permission denied. Cannot add the role." ) ;
311319 } ) ;
320+
312321 it ( "should not allow role to be added when userid does not belong to authenticated user" , async function ( ) {
313322 const res = await chai
314323 . request ( app )
@@ -321,6 +330,7 @@ describe("Discord actions", function () {
321330 expect ( res . body . message ) . to . equal ( "Permission denied. Cannot add the role." ) ;
322331 } ) ;
323332 } ) ;
333+
324334 describe ( "DELETE /discord-actions/roles" , function ( ) {
325335 let roleid ;
326336
@@ -385,6 +395,7 @@ describe("Discord actions", function () {
385395 `Action initiator's username=>ankur and id=${ userId } `
386396 ) ;
387397 } ) ;
398+
388399 it ( "should not allow unknown role to be deleted from user" , async function ( ) {
389400 const res = await chai
390401 . request ( app )
@@ -396,6 +407,7 @@ describe("Discord actions", function () {
396407 expect ( res . body ) . to . be . an ( "object" ) ;
397408 expect ( res . body . message ) . to . equal ( "Permission denied. Cannot delete the role." ) ;
398409 } ) ;
410+
399411 it ( "should not allow role to be deleted when userid does not belong to authenticated user" , async function ( ) {
400412 const res = await chai
401413 . request ( app )
@@ -407,6 +419,7 @@ describe("Discord actions", function () {
407419 expect ( res . body ) . to . be . an ( "object" ) ;
408420 expect ( res . body . message ) . to . equal ( "Permission denied. Cannot delete the role." ) ;
409421 } ) ;
422+
410423 it ( "should handle internal server error" , function ( done ) {
411424 chai
412425 . request ( app )
@@ -472,6 +485,7 @@ describe("Discord actions", function () {
472485
473486 describe ( "POST /discord-actions/nickname/status" , function ( ) {
474487 let jwtToken ;
488+
475489 beforeEach ( async function ( ) {
476490 const userData2 = { ...userData [ 1 ] } ;
477491 delete userData2 . discordId ;
@@ -562,6 +576,7 @@ describe("Discord actions", function () {
562576 } ) ;
563577 } ) . timeout ( 10000 ) ;
564578 } ) ;
579+
565580 describe ( "POST /discord-actions/discord-roles" , function ( ) {
566581 before ( async function ( ) {
567582 const value = [ discordRoleModel . add ( groupData [ 0 ] ) , discordRoleModel . add ( groupData [ 1 ] ) ] ;
@@ -596,6 +611,7 @@ describe("Discord actions", function () {
596611
597612 describe ( "PUT /discord-actions/group-idle-7d" , function ( ) {
598613 let allIds ;
614+
599615 beforeEach ( async function ( ) {
600616 userData [ 0 ] . roles = { archived : false } ;
601617 userData [ 1 ] . roles = { archived : false } ;
@@ -695,6 +711,7 @@ describe("Discord actions", function () {
695711 } )
696712 ) ;
697713 } ) ;
714+
698715 afterEach ( async function ( ) {
699716 sinon . restore ( ) ;
700717 await cleanDb ( ) ;
0 commit comments