@@ -17,7 +17,6 @@ const userData = require("../fixtures/user/user")();
1717const userModel = firestore . collection ( "users" ) ;
1818const tasksModel = firestore . collection ( "tasks" ) ;
1919const { EXTERNAL_ACCOUNTS_POST_ACTIONS } = require ( "../../constants/external-accounts" ) ;
20- const removeDiscordRoleUtils = require ( "../../utils/removeDiscordRole" ) ;
2120chai . use ( chaiHttp ) ;
2221const cookieName = config . get ( "userToken.cookieName" ) ;
2322
@@ -538,11 +537,6 @@ describe("External Accounts", function () {
538537 expect ( getUserResponseBeforeUpdate . body ) . to . not . have . property ( "discordId" ) ;
539538 expect ( getUserResponseBeforeUpdate . body ) . to . not . have . property ( "discordJoinedAt" ) ;
540539
541- const removeDiscordRoleStub = Sinon . stub ( removeDiscordRoleUtils , "removeDiscordRole" ) . resolves ( {
542- success : true ,
543- message : "Role deleted successfully" ,
544- } ) ;
545-
546540 const response = await chai
547541 . request ( app )
548542 . patch ( `/external-accounts/link/${ externalAccountData [ 2 ] . token } ` )
@@ -559,60 +553,6 @@ describe("External Accounts", function () {
559553 expect ( updatedUserDetails . body . roles . in_discord ) . to . equal ( true ) ;
560554 expect ( updatedUserDetails . body ) . to . have . property ( "discordId" ) ;
561555 expect ( updatedUserDetails . body ) . to . have . property ( "discordJoinedAt" ) ;
562-
563- removeDiscordRoleStub . restore ( ) ;
564- } ) ;
565-
566- it ( "Should return 500 when removeDiscordRole fails because role doesn't exist" , async function ( ) {
567- await externalAccountsModel . addExternalAccountData ( externalAccountData [ 2 ] ) ;
568-
569- const removeDiscordRoleStub = Sinon . stub ( removeDiscordRoleUtils , "removeDiscordRole" ) . resolves ( {
570- success : false ,
571- message : "Role doesn't exist" ,
572- } ) ;
573-
574- const response = await chai
575- . request ( app )
576- . patch ( `/external-accounts/link/${ externalAccountData [ 2 ] . token } ` )
577- . query ( { action : EXTERNAL_ACCOUNTS_POST_ACTIONS . DISCORD_USERS_SYNC } )
578- . set ( "Cookie" , `${ cookieName } =${ newUserJWT } ` ) ;
579-
580- const unverifiedRoleRemovalResponse = await removeDiscordRoleStub ( ) ;
581-
582- expect ( response ) . to . have . status ( 500 ) ;
583- expect ( response . body ) . to . be . an ( "object" ) ;
584- expect ( response . body ) . to . have . property ( "message" ) ;
585- expect ( response . body . message ) . to . equal (
586- `User details updated but ${ unverifiedRoleRemovalResponse . message } . Please contact admin`
587- ) ;
588-
589- removeDiscordRoleStub . restore ( ) ;
590- } ) ;
591-
592- it ( "Should return 500 when removeDiscordRole fails because role deletion failed" , async function ( ) {
593- await externalAccountsModel . addExternalAccountData ( externalAccountData [ 2 ] ) ;
594-
595- const removeDiscordRoleStub = Sinon . stub ( removeDiscordRoleUtils , "removeDiscordRole" ) . resolves ( {
596- success : false ,
597- message : "Role deletion failed" ,
598- } ) ;
599-
600- const response = await chai
601- . request ( app )
602- . patch ( `/external-accounts/link/${ externalAccountData [ 2 ] . token } ` )
603- . query ( { action : EXTERNAL_ACCOUNTS_POST_ACTIONS . DISCORD_USERS_SYNC } )
604- . set ( "Cookie" , `${ cookieName } =${ newUserJWT } ` ) ;
605-
606- const unverifiedRoleRemovalResponse = await removeDiscordRoleStub ( ) ;
607-
608- expect ( response ) . to . have . status ( 500 ) ;
609- expect ( response . body ) . to . be . an ( "object" ) ;
610- expect ( response . body ) . to . have . property ( "message" ) ;
611- expect ( response . body . message ) . to . equal (
612- `User details updated but ${ unverifiedRoleRemovalResponse . message } . Please contact admin`
613- ) ;
614-
615- removeDiscordRoleStub . restore ( ) ;
616556 } ) ;
617557 } ) ;
618558} ) ;
0 commit comments