From 5cbd669a5d740c30628d74b0b7545ba79f34abb3 Mon Sep 17 00:00:00 2001 From: aditya Date: Wed, 7 Feb 2024 18:42:31 +0530 Subject: [PATCH 1/4] added all the code --- README.md | 9 +- codegen.ts | 2 + sample_data/userFamilies.json | 20 ++ schema.graphql | 17 ++ src/constants.ts | 12 + src/models/User.ts | 3 +- src/models/userFamily.ts | 56 ++++ src/resolvers/Mutation/addUserToUserFamily.ts | 82 +++++ src/resolvers/Mutation/createUserFamily.ts | 81 +++++ src/resolvers/Mutation/index.ts | 8 + src/resolvers/Mutation/removeUserFamily.ts | 60 ++++ .../Mutation/removeUserFromUserFamily.ts | 129 ++++++++ src/resolvers/UserFamily/admins.ts | 14 + src/resolvers/UserFamily/creator.ts | 24 ++ src/resolvers/UserFamily/index.ts | 10 + src/resolvers/UserFamily/users.ts | 14 + src/resolvers/index.ts | 4 +- src/typeDefs/inputs.ts | 5 + src/typeDefs/mutations.ts | 8 + src/typeDefs/types.ts | 8 + src/types/generatedGraphQLTypes.ts | 59 ++++ src/utilities/userFamilyAdminCheck.ts | 36 +++ tests/helpers/userAndUserFamily.ts | 75 +++++ .../Mutation/addUserToUserFamily.spec.ts | 154 ++++++++++ .../Mutation/createUserFamily.spec.ts | 189 ++++++++++++ .../Mutation/removeUserFamily.spec.ts | 139 +++++++++ .../Mutation/removeUserFromUserFamily.spec.ts | 289 ++++++++++++++++++ tests/resolvers/UserFamily/admins.spec.ts | 39 +++ tests/resolvers/UserFamily/creator.spec.ts | 111 +++++++ tests/resolvers/UserFamily/users.spec.ts | 39 +++ tests/utilities/userFamilyAdminCheck.spec.ts | 153 ++++++++++ 31 files changed, 1841 insertions(+), 8 deletions(-) create mode 100644 sample_data/userFamilies.json create mode 100644 src/models/userFamily.ts create mode 100644 src/resolvers/Mutation/addUserToUserFamily.ts create mode 100644 src/resolvers/Mutation/createUserFamily.ts create mode 100644 src/resolvers/Mutation/removeUserFamily.ts create mode 100644 src/resolvers/Mutation/removeUserFromUserFamily.ts create mode 100644 src/resolvers/UserFamily/admins.ts create mode 100644 src/resolvers/UserFamily/creator.ts create mode 100644 src/resolvers/UserFamily/index.ts create mode 100644 src/resolvers/UserFamily/users.ts create mode 100644 src/utilities/userFamilyAdminCheck.ts create mode 100644 tests/helpers/userAndUserFamily.ts create mode 100644 tests/resolvers/Mutation/addUserToUserFamily.spec.ts create mode 100644 tests/resolvers/Mutation/createUserFamily.spec.ts create mode 100644 tests/resolvers/Mutation/removeUserFamily.spec.ts create mode 100644 tests/resolvers/Mutation/removeUserFromUserFamily.spec.ts create mode 100644 tests/resolvers/UserFamily/admins.spec.ts create mode 100644 tests/resolvers/UserFamily/creator.spec.ts create mode 100644 tests/resolvers/UserFamily/users.spec.ts create mode 100644 tests/utilities/userFamilyAdminCheck.spec.ts diff --git a/README.md b/README.md index 17c17f46269..bdacd57db57 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,10 @@ Core features include: -- [Talawa API](#talawa-api) - - [Talawa Components](#talawa-components) - - [Documentation](#documentation) - - [Installation](#installation) - - [Image Upload](#image-upload) +- [Talawa Components](#talawa-components) +- [Documentation](#documentation) +- [Installation](#installation) +- [Image Upload](#image-upload) diff --git a/codegen.ts b/codegen.ts index 47f6985cadf..3f49de49f01 100644 --- a/codegen.ts +++ b/codegen.ts @@ -47,6 +47,8 @@ const config: CodegenConfig = { EventAttendee: "../models/EventAttendee#InterfaceEventAttendee", + UserFamily: "../models/userFamily#InterfaceUserFamily", + Feedback: "../models/Feedback#InterfaceFeedback", // File: '../models/File#InterfaceFile', diff --git a/sample_data/userFamilies.json b/sample_data/userFamilies.json new file mode 100644 index 00000000000..b936f133662 --- /dev/null +++ b/sample_data/userFamilies.json @@ -0,0 +1,20 @@ +[ + { + "_id": "60f18f31b7e5c4a2a4c3f905", + "title": "Smith Family", + "users": [ + "64378abd85008f171cf2990d", + "65378abd85008f171cf2990d", + "66378abd85008f171cf2990d" + ] + }, + { + "_id": "60f18f31b7e5c4a2a4c3f906", + "title": "Johnson Family", + "users": [ + "66378abd85008f171cf2990d", + "65378abd85008f171cf2990d", + "64378abd85008f171cf2990d" + ] + } +] diff --git a/schema.graphql b/schema.graphql index 8ea527723c2..19d7ad4b4dd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -521,6 +521,7 @@ type Mutation { addUserCustomData(dataName: String!, dataValue: Any!, organizationId: ID!): UserCustomData! addUserImage(file: String!): User! addUserToGroupChat(chatId: ID!, userId: ID!): GroupChat! + addUserToUserFamily(familyId: ID!, userId: ID!): UserFamily! adminRemoveEvent(eventId: ID!): Event! adminRemoveGroup(groupId: ID!): GroupChat! assignUserTag(input: ToggleUserTagAssignInput!): User @@ -543,6 +544,7 @@ type Mutation { createPlugin(pluginCreatedBy: String!, pluginDesc: String!, pluginName: String!, uninstalledOrgs: [ID!]): Plugin! createPost(data: PostInput!, file: String): Post createSampleOrganization: Boolean! + createUserFamily(data: createUserFamilyInput!): UserFamily! createUserTag(input: CreateUserTagInput!): UserTag deleteAdvertisementById(id: ID!): DeletePayload! deleteDonationById(id: ID!): DeletePayload! @@ -574,7 +576,9 @@ type Mutation { removePost(id: ID!): Post removeSampleOrganization: Boolean! removeUserCustomData(organizationId: ID!): UserCustomData! + removeUserFamily(familyId: ID!): UserFamily! removeUserFromGroupChat(chatId: ID!, userId: ID!): GroupChat! + removeUserFromUserFamily(familyId: ID!, userId: ID!): UserFamily! removeUserImage: User! removeUserTag(id: ID!): UserTag revokeRefreshTokenForUser: Boolean! @@ -1073,6 +1077,14 @@ type UserEdge { node: User! } +type UserFamily { + _id: ID! + admins: [User!]! + creator: User! + title: String + users: [User!]! +} + input UserInput { appLanguageCode: String email: EmailAddress! @@ -1204,4 +1216,9 @@ input createGroupChatInput { organizationId: ID! title: String! userIds: [ID!]! +} + +input createUserFamilyInput { + title: String! + userIds: [ID!]! } \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index e5945d74540..b454f7e6761 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -177,12 +177,24 @@ export const LENGTH_VALIDATION_ERROR = { PARAM: "stringValidation", }; +export const USER_FAMILY_MIN_MEMBERS_ERROR_CODE = { + MESSAGE: "InputValidationError", + CODE: "membersInUserFamilyLessThanOne", + PARAM: "membersInUserFamilyLessThanOne", +}; + export const REGEX_VALIDATION_ERROR = { MESSAGE: "Error: Entered value must be a valid string", CODE: "string.notValid", PARAM: "stringValidation", }; +export const USER_FAMILY_NOT_FOUND_ERROR = { + MESSAGE: "Error: User Family Not Found", + CODE: "userfamilyNotFound", + PARAM: "userfamilyNotFound", +}; + export const USER_NOT_AUTHORIZED_SUPERADMIN = { MESSAGE: "Error: Current user must be a SUPERADMIN", CODE: "role.notValid.superadmin", diff --git a/src/models/User.ts b/src/models/User.ts index 8f8eb098be5..6d5d8b53d2a 100644 --- a/src/models/User.ts +++ b/src/models/User.ts @@ -6,7 +6,6 @@ import type { InterfaceEvent } from "./Event"; import type { InterfaceMembershipRequest } from "./MembershipRequest"; import type { InterfaceOrganization } from "./Organization"; import { createLoggingMiddleware } from "../libraries/dbLogger"; -import { LOG } from "../constants"; /** * This is an interface that represents a database(MongoDB) document for User. @@ -278,7 +277,7 @@ const userSchema = new Schema( }, { timestamps: true, - } + }, ); userSchema.plugin(mongoosePaginate); diff --git a/src/models/userFamily.ts b/src/models/userFamily.ts new file mode 100644 index 00000000000..a9d8577ea41 --- /dev/null +++ b/src/models/userFamily.ts @@ -0,0 +1,56 @@ +import type { PopulatedDoc, Types, Document, Model } from "mongoose"; +import { Schema, model, models } from "mongoose"; +import type { InterfaceUser } from "./User"; +/** + * This is an interface that represents a database(MongoDB) document for Family. + */ + +export interface InterfaceUserFamily { + _id: Types.ObjectId; + title: string; + users: PopulatedDoc[]; + admins: PopulatedDoc[]; + creator: PopulatedDoc[]; +} + +/** + * @param title - Name of the user Family (type: String) + * Description: Name of the user Family. + */ + +/** + * @param users - Members associated with the user Family (type: String) + * Description: Members associated with the user Family. + */ +const userFamilySchema = new Schema({ + title: { + type: String, + required: true, + }, + users: [ + { + type: Schema.Types.ObjectId, + ref: "User", + required: true, + }, + ], + admins: [ + { + type: Schema.Types.ObjectId, + ref: "User", + required: true, + }, + ], + creator: { + type: Schema.Types.ObjectId, + ref: "User", + required: true, + }, +}); + +const userFamilyModel = (): Model => + model("UserFamily", userFamilySchema); + +// This syntax is needed to prevent Mongoose OverwriteModelError while running tests. +export const UserFamily = (models.UserFamily || + userFamilyModel()) as ReturnType; diff --git a/src/resolvers/Mutation/addUserToUserFamily.ts b/src/resolvers/Mutation/addUserToUserFamily.ts new file mode 100644 index 00000000000..cb9cbe1dc06 --- /dev/null +++ b/src/resolvers/Mutation/addUserToUserFamily.ts @@ -0,0 +1,82 @@ +import "dotenv/config"; +import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; +import { errors, requestContext } from "../../libraries"; +import { adminCheck } from "../../utilities/userFamilyAdminCheck"; +import { User } from "../../models"; +import { UserFamily } from "../../models/userFamily"; +import { + USER_FAMILY_NOT_FOUND_ERROR, + USER_ALREADY_MEMBER_ERROR, + USER_NOT_FOUND_ERROR, +} from "../../constants"; +/** + * This function adds user to the family. + * @param _parent - parent of current request + * @param args - payload provided with the request + * @param context - context of the entire application + * @remarks The following checks are done: + * 1. If the family exists + * 2. If the user exists + * 3. If the user is already member of the family + * 4. If the user is admin of the user Family + * @returns Updated family + */ +export const addUserToUserFamily: MutationResolvers["addUserToUserFamily"] = + async (_parent, args, context) => { + const userFamily = await UserFamily.findOne({ + _id: args.familyId, + }).lean(); + + const currentUser = await User.findById({ + _id: context.userId, + }); + + // Checks whether user with _id === args.userId exists. + if (currentUser === null) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + //check wheather family exists + if (!userFamily) { + throw new errors.NotFoundError( + requestContext.translate(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE), + USER_FAMILY_NOT_FOUND_ERROR.CODE, + USER_FAMILY_NOT_FOUND_ERROR.PARAM, + ); + } + + //check whether user is admin of the family + await adminCheck(currentUser?._id, userFamily); + + const isUserMemberOfUserFamily = userFamily.users.some((user) => { + user.equals(args.userId); + }); + + // Checks whether user with _id === args.userId is already a member of Family. + if (isUserMemberOfUserFamily) { + throw new errors.ConflictError( + requestContext.translate(USER_ALREADY_MEMBER_ERROR.MESSAGE), + USER_ALREADY_MEMBER_ERROR.CODE, + USER_ALREADY_MEMBER_ERROR.PARAM, + ); + } + + // Adds args.userId to users lists on family group and return the updated family. + return await UserFamily.findOneAndUpdate( + { + _id: args.familyId, + }, + { + $push: { + users: args.userId, + }, + }, + { + new: true, + }, + ).lean(); + }; diff --git a/src/resolvers/Mutation/createUserFamily.ts b/src/resolvers/Mutation/createUserFamily.ts new file mode 100644 index 00000000000..99e2bcccd15 --- /dev/null +++ b/src/resolvers/Mutation/createUserFamily.ts @@ -0,0 +1,81 @@ +import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; +import { User } from "../../models"; +import { errors, requestContext } from "../../libraries"; +import { + LENGTH_VALIDATION_ERROR, + USER_FAMILY_MIN_MEMBERS_ERROR_CODE, + USER_NOT_FOUND_ERROR, +} from "../../constants"; +import { isValidString } from "../../libraries/validators/validateString"; +import { UserFamily } from "../../models/userFamily"; +import { superAdminCheck } from "../../utilities"; +/** + * This Function enables to create a user Family + * @param _parent - parent of current request + * @param args - payload provided with the request + * @param context - context of entire application + * @remarks - The following checks are done: + * 1. If the user exists + * 2. If the user is super admin + * 3. If there are atleast two members in the family. + * @returns Created user Family + */ +export const createUserFamily: MutationResolvers["createUserFamily"] = async ( + _parent, + args, + context, +) => { + const currentUser = await User.findById({ + _id: context.userId, + }); + + // Checks whether user with _id === args.userId exists. + if (!currentUser) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + // Check whether the user is super admin. + superAdminCheck(currentUser); + + let validationResultName = { + isLessThanMaxLength: false, + }; + + if (args && args.data && typeof args.data.title === "string") { + validationResultName = isValidString(args.data.title, 256); + } + + if (!validationResultName.isLessThanMaxLength) { + throw new errors.InputValidationError( + requestContext.translate( + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name`, + ), + LENGTH_VALIDATION_ERROR.CODE, + ); + } + + // Check if there are at least 2 members + if (args.data?.userIds.length < 2) { + throw new errors.InputValidationError( + requestContext.translate(USER_FAMILY_MIN_MEMBERS_ERROR_CODE.MESSAGE), + USER_FAMILY_MIN_MEMBERS_ERROR_CODE.CODE, + USER_FAMILY_MIN_MEMBERS_ERROR_CODE.PARAM, + ); + } + + const userfamilyTitle = args.data?.title; + + const createdUserFamily = await UserFamily.create({ + ...args.data, + title: userfamilyTitle, + users: [context.userId, ...args.data.userIds], + admins: [context.userId], + creator: context.userId, + }); + + return createdUserFamily.toObject(); +}; diff --git a/src/resolvers/Mutation/index.ts b/src/resolvers/Mutation/index.ts index 68e6c4c916c..2d3332bcf80 100644 --- a/src/resolvers/Mutation/index.ts +++ b/src/resolvers/Mutation/index.ts @@ -53,6 +53,10 @@ import { removeComment } from "./removeComment"; import { removeDirectChat } from "./removeDirectChat"; import { removeEvent } from "./removeEvent"; import { removeEventAttendee } from "./removeEventAttendee"; +import { addUserToUserFamily } from "./addUserToUserFamily"; +import { removeUserFromUserFamily } from "./removeUserFromUserFamily"; +import { removeUserFamily } from "./removeUserFamily"; +import { createUserFamily } from "./createUserFamily"; import { removeGroupChat } from "./removeGroupChat"; import { removeAdvertisement } from "./removeAdvertisement"; import { removeMember } from "./removeMember"; @@ -104,6 +108,10 @@ export const Mutation: MutationResolvers = { addUserToGroupChat, adminRemoveEvent, adminRemoveGroup, + addUserToUserFamily, + removeUserFamily, + removeUserFromUserFamily, + createUserFamily, assignUserTag, blockPluginCreationBySuperadmin, blockUser, diff --git a/src/resolvers/Mutation/removeUserFamily.ts b/src/resolvers/Mutation/removeUserFamily.ts new file mode 100644 index 00000000000..0d9ff3b4fd5 --- /dev/null +++ b/src/resolvers/Mutation/removeUserFamily.ts @@ -0,0 +1,60 @@ +import { + USER_FAMILY_NOT_FOUND_ERROR, + USER_NOT_FOUND_ERROR, +} from "../../constants"; +import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; +import { errors, requestContext } from "../../libraries"; +import { UserFamily } from "../../models/userFamily"; +import { User } from "../../models"; +import { superAdminCheck } from "../../utilities"; +/** + * This function enables to remove a user family. + * @param _parent - parent of current request + * @param args - payload provided with the request + * @param context - context of entire application. + * @remarks - The following checks are done: + * 1. If the user family exists. + * 2. If the user is super admin. + * @returns Deleted user family. + */ +export const removeUserFamily: MutationResolvers["removeUserFamily"] = async ( + _parent, + args, + context, +) => { + const userFamily = await UserFamily.findOne({ + _id: args.familyId, + }).lean(); + + const currentUser = await User.findOne({ + _id: context.userId, + }); + + // Checks whether currentUser exists. + if (!currentUser) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + // Checks whether currentUser is a SUPERADMIN + superAdminCheck(currentUser); + + // Checks if a family with _id === args.familyId exists + if (!userFamily) { + throw new errors.NotFoundError( + requestContext.translate(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE), + USER_FAMILY_NOT_FOUND_ERROR.CODE, + USER_FAMILY_NOT_FOUND_ERROR.PARAM, + ); + } + + // Deletes the UserFamily. + await UserFamily.deleteOne({ + _id: userFamily._id, + }); + + return userFamily; +}; diff --git a/src/resolvers/Mutation/removeUserFromUserFamily.ts b/src/resolvers/Mutation/removeUserFromUserFamily.ts new file mode 100644 index 00000000000..95ebc1bb1fb --- /dev/null +++ b/src/resolvers/Mutation/removeUserFromUserFamily.ts @@ -0,0 +1,129 @@ +import { + ADMIN_REMOVING_ADMIN, + ADMIN_REMOVING_CREATOR, + USER_FAMILY_NOT_FOUND_ERROR, + USER_NOT_FOUND_ERROR, + USER_REMOVING_SELF, +} from "../../constants"; +import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; +import { errors, requestContext } from "../../libraries"; +import { User } from "../../models"; +import { UserFamily } from "../../models/userFamily"; +import { adminCheck } from "../../utilities/userFamilyAdminCheck"; +import { Types } from "mongoose"; +/** + * This function enables to remove a user from group chat. + * @param _parent - parent of current request + * @param args - payload provided with the request + * @param context - context of entire publication + * @remarks The following checks are done: + * 1. If the family exists. + * 2. If the user to be removed is member of the organisation. + * 3. If the user is admin of the family + * @returns Updated group chat. + */ +export const removeUserFromUserFamily: MutationResolvers["removeUserFromUserFamily"] = + async (_parent, args, context) => { + const userFamily = await UserFamily.findById({ + _id: args.familyId, + }).lean(); + + const currentUser = await User.findById({ + _id: context.userId, + }); + + const user = await User.findById({ + _id: args.userId, + }); + + // Check whether the user exists. + if (!user) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + const userIsMemberOfUserFamily = userFamily?.users.some((member) => { + return Types.ObjectId(member).equals(user?._id); + }); + + const userIdUserFamilyAdmin = userFamily?.admins.some((admin) => { + Types.ObjectId(admin).equals(user?._id); + }); + + //Check whether user family exists. + if (!userFamily) { + throw new errors.NotFoundError( + requestContext.translate(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE), + USER_FAMILY_NOT_FOUND_ERROR.CODE, + USER_FAMILY_NOT_FOUND_ERROR.PARAM, + ); + } + + //check whether user is admin of the family. + await adminCheck(currentUser?._id, userFamily); + + //Check whether user is member of the family. + if (!userIsMemberOfUserFamily) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + // Check if the current user is removing self + if (user._id.equals(currentUser?._id)) { + throw new errors.ConflictError( + requestContext.translate(USER_REMOVING_SELF.MESSAGE), + USER_REMOVING_SELF.CODE, + USER_REMOVING_SELF.PARAM, + ); + } + + /* + userIsUserFamilyAdmin being true implies that the current user is an admin of userFamily. + If userIsUserFamilyAdmin is true pushes error message to errors list and breaks out of loop. + */ + if (userIdUserFamilyAdmin) { + throw new errors.ConflictError( + requestContext.translate(ADMIN_REMOVING_ADMIN.MESSAGE), + ADMIN_REMOVING_ADMIN.CODE, + ADMIN_REMOVING_ADMIN.PARAM, + ); + } + + /* + Administrators cannot remove creator of userFamily from the members list. + Following if block matches userFamily's creator's id to + user's id. Match being true implies that current user is the creator + of userFamily. If match is true assigns error message to errors list + and breaks out of loop. + */ + if (Types.ObjectId(userFamily.creator.toString()).equals(user._id)) { + throw new errors.UnauthorizedError( + requestContext.translate(ADMIN_REMOVING_CREATOR.MESSAGE), + ADMIN_REMOVING_CREATOR.CODE, + ADMIN_REMOVING_CREATOR.PARAM, + ); + } + + //Removes args.userId from users list of user family ans return the updated family. + return await UserFamily.findOneAndUpdate( + { + _id: args.familyId, + }, + { + $set: { + users: userFamily.users.filter( + (user) => user.toString() !== args.userId.toString(), + ), + }, + }, + { + new: true, + }, + ).lean(); + }; diff --git a/src/resolvers/UserFamily/admins.ts b/src/resolvers/UserFamily/admins.ts new file mode 100644 index 00000000000..9571bd0c021 --- /dev/null +++ b/src/resolvers/UserFamily/admins.ts @@ -0,0 +1,14 @@ +import { User } from "../../models"; +import type { UserFamilyResolvers } from "../../types/generatedGraphQLTypes"; +/** + * This resolver function will fetch and return the admins of the Organization from database. + * @param parent - An object that is the return value of the resolver for this field's parent. + * @returns An object that contains the list of all admins of the organization. + */ +export const admins: UserFamilyResolvers["admins"] = async (parent) => { + return await User.find({ + _id: { + $in: parent.admins, + }, + }).lean(); +}; diff --git a/src/resolvers/UserFamily/creator.ts b/src/resolvers/UserFamily/creator.ts new file mode 100644 index 00000000000..69fb4b7e3b5 --- /dev/null +++ b/src/resolvers/UserFamily/creator.ts @@ -0,0 +1,24 @@ +import { User } from "../../models"; +import { errors, requestContext } from "../../libraries"; +import type { UserFamilyResolvers } from "../../types/generatedGraphQLTypes"; +import { USER_NOT_FOUND_ERROR } from "../../constants"; +/** + * This resolver function will fetch and return the creator of the Organization from database. + * @param parent - An object that is the return value of the resolver for this field's parent. + * @returns An object that contains the creator data. If the creator not exists then throws an `NotFoundError` error. + */ +export const creator: UserFamilyResolvers["creator"] = async (parent) => { + const user = await User.findOne({ + _id: parent.creator.toString(), + }).lean(); + + if (!user) { + throw new errors.NotFoundError( + requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), + USER_NOT_FOUND_ERROR.CODE, + USER_NOT_FOUND_ERROR.PARAM, + ); + } + + return user; +}; diff --git a/src/resolvers/UserFamily/index.ts b/src/resolvers/UserFamily/index.ts new file mode 100644 index 00000000000..a89939e37d6 --- /dev/null +++ b/src/resolvers/UserFamily/index.ts @@ -0,0 +1,10 @@ +import type { UserFamilyResolvers } from "../../types/generatedGraphQLTypes"; +import { users } from "./users"; +import { admins } from "./admins"; +import { creator } from "./creator"; + +export const UserFamily: UserFamilyResolvers = { + users, + admins, + creator, +}; diff --git a/src/resolvers/UserFamily/users.ts b/src/resolvers/UserFamily/users.ts new file mode 100644 index 00000000000..c02ba909f47 --- /dev/null +++ b/src/resolvers/UserFamily/users.ts @@ -0,0 +1,14 @@ +import type { UserFamilyResolvers } from "../../types/generatedGraphQLTypes"; +import { User } from "../../models"; +/** + * This resolver function will fetch and return the list of all Members of the user family from database. + * @param parent - An object that is the return value of the resolver for this field's parent. + * @returns An `object` that contains the Member data. + */ +export const users: UserFamilyResolvers["users"] = async (parent) => { + return await User.find({ + _id: { + $in: parent.users, + }, + }).lean(); +}; diff --git a/src/resolvers/index.ts b/src/resolvers/index.ts index 7ded81a68fb..810a396f59e 100644 --- a/src/resolvers/index.ts +++ b/src/resolvers/index.ts @@ -11,6 +11,7 @@ import { GroupChat } from "./GroupChat"; import { GroupChatMessage } from "./GroupChatMessage"; import { MembershipRequest } from "./MembershipRequest"; import { Mutation } from "./Mutation"; +import { UserFamily } from "./UserFamily"; import { Organization } from "./Organization"; import { Post } from "./Post"; import { Query } from "./Query"; @@ -42,6 +43,7 @@ const resolvers: Resolvers = { Event, Feedback, GroupChat, + UserFamily, GroupChatMessage, MembershipRequest, Mutation, @@ -91,5 +93,5 @@ const resolversComposition = { export const composedResolvers: Resolvers = composeResolvers( resolvers, - resolversComposition + resolversComposition, ); diff --git a/src/typeDefs/inputs.ts b/src/typeDefs/inputs.ts index e4aa13d73ef..d0bdd94af42 100644 --- a/src/typeDefs/inputs.ts +++ b/src/typeDefs/inputs.ts @@ -29,6 +29,11 @@ export const inputs = gql` title: String! } + input createUserFamilyInput { + title: String! + userIds: [ID!]! + } + input CreateUserTagInput { name: String! parentTagId: ID diff --git a/src/typeDefs/mutations.ts b/src/typeDefs/mutations.ts index 1843e921412..a2439dccefb 100644 --- a/src/typeDefs/mutations.ts +++ b/src/typeDefs/mutations.ts @@ -34,6 +34,14 @@ export const mutations = gql` addUserToGroupChat(userId: ID!, chatId: ID!): GroupChat! @auth + addUserToUserFamily(userId: ID!, familyId: ID!): UserFamily! @auth + + removeUserFromUserFamily(userId: ID!, familyId: ID!): UserFamily! @auth + + removeUserFamily(familyId: ID!): UserFamily! @auth + + createUserFamily(data: createUserFamilyInput!): UserFamily! @auth + adminRemoveEvent(eventId: ID!): Event! @auth adminRemoveGroup(groupId: ID!): GroupChat! @auth diff --git a/src/typeDefs/types.ts b/src/typeDefs/types.ts index c58764ccbe8..1923a9a37ae 100644 --- a/src/typeDefs/types.ts +++ b/src/typeDefs/types.ts @@ -75,6 +75,14 @@ export const types = gql` updatedAt: DateTime! } + type UserFamily { + _id: ID! + title: String + users: [User!]! + admins: [User!]! + creator: User! + } + # A page info type adhering to Relay Specification for both cursor based pagination type ConnectionPageInfo { hasNextPage: Boolean! diff --git a/src/types/generatedGraphQLTypes.ts b/src/types/generatedGraphQLTypes.ts index fd68a701a12..161abec3184 100644 --- a/src/types/generatedGraphQLTypes.ts +++ b/src/types/generatedGraphQLTypes.ts @@ -9,6 +9,7 @@ import type { InterfaceDirectChatMessage as InterfaceDirectChatMessageModel } fr import type { InterfaceDonation as InterfaceDonationModel } from '../models/Donation'; import type { InterfaceEvent as InterfaceEventModel } from '../models/Event'; import type { InterfaceEventAttendee as InterfaceEventAttendeeModel } from '../models/EventAttendee'; +import type { InterfaceUserFamily as InterfaceUserFamilyModel } from '../models/userFamily'; import type { InterfaceFeedback as InterfaceFeedbackModel } from '../models/Feedback'; import type { InterfaceGroup as InterfaceGroupModel } from '../models/Group'; import type { InterfaceGroupChat as InterfaceGroupChatModel } from '../models/GroupChat'; @@ -587,6 +588,7 @@ export type Mutation = { addUserCustomData: UserCustomData; addUserImage: User; addUserToGroupChat: GroupChat; + addUserToUserFamily: UserFamily; adminRemoveEvent: Event; adminRemoveGroup: GroupChat; assignUserTag?: Maybe; @@ -609,6 +611,7 @@ export type Mutation = { createPlugin: Plugin; createPost?: Maybe; createSampleOrganization: Scalars['Boolean']['output']; + createUserFamily: UserFamily; createUserTag?: Maybe; deleteAdvertisementById: DeletePayload; deleteDonationById: DeletePayload; @@ -640,7 +643,9 @@ export type Mutation = { removePost?: Maybe; removeSampleOrganization: Scalars['Boolean']['output']; removeUserCustomData: UserCustomData; + removeUserFamily: UserFamily; removeUserFromGroupChat: GroupChat; + removeUserFromUserFamily: UserFamily; removeUserImage: User; removeUserTag?: Maybe; revokeRefreshTokenForUser: Scalars['Boolean']['output']; @@ -727,6 +732,12 @@ export type MutationAddUserToGroupChatArgs = { }; +export type MutationAddUserToUserFamilyArgs = { + familyId: Scalars['ID']['input']; + userId: Scalars['ID']['input']; +}; + + export type MutationAdminRemoveEventArgs = { eventId: Scalars['ID']['input']; }; @@ -852,6 +863,11 @@ export type MutationCreatePostArgs = { }; +export type MutationCreateUserFamilyArgs = { + data: CreateUserFamilyInput; +}; + + export type MutationCreateUserTagArgs = { input: CreateUserTagInput; }; @@ -999,12 +1015,23 @@ export type MutationRemoveUserCustomDataArgs = { }; +export type MutationRemoveUserFamilyArgs = { + familyId: Scalars['ID']['input']; +}; + + export type MutationRemoveUserFromGroupChatArgs = { chatId: Scalars['ID']['input']; userId: Scalars['ID']['input']; }; +export type MutationRemoveUserFromUserFamilyArgs = { + familyId: Scalars['ID']['input']; + userId: Scalars['ID']['input']; +}; + + export type MutationRemoveUserTagArgs = { id: Scalars['ID']['input']; }; @@ -1829,6 +1856,15 @@ export type UserEdge = { node: User; }; +export type UserFamily = { + __typename?: 'UserFamily'; + _id: Scalars['ID']['output']; + admins: Array; + creator: User; + title?: Maybe; + users: Array; +}; + export type UserInput = { appLanguageCode?: InputMaybe; email: Scalars['EmailAddress']['input']; @@ -1977,6 +2013,11 @@ export type CreateGroupChatInput = { userIds: Array; }; +export type CreateUserFamilyInput = { + title: Scalars['String']['input']; + userIds: Array; +}; + export type ResolverTypeWrapper = Promise | T; @@ -2172,6 +2213,7 @@ export type ResolversTypes = { UserConnection: ResolverTypeWrapper & { edges: Array> }>; UserCustomData: ResolverTypeWrapper; UserEdge: ResolverTypeWrapper & { node: ResolversTypes['User'] }>; + UserFamily: ResolverTypeWrapper; UserInput: UserInput; UserOrderByInput: UserOrderByInput; UserPhone: ResolverTypeWrapper; @@ -2188,6 +2230,7 @@ export type ResolversTypes = { UsersConnectionResult: ResolverTypeWrapper & { data?: Maybe, errors: Array }>; createChatInput: CreateChatInput; createGroupChatInput: CreateGroupChatInput; + createUserFamilyInput: CreateUserFamilyInput; }; /** Mapping between all available schema types and the resolvers parents */ @@ -2299,6 +2342,7 @@ export type ResolversParentTypes = { UserConnection: Omit & { edges: Array> }; UserCustomData: UserCustomData; UserEdge: Omit & { node: ResolversParentTypes['User'] }; + UserFamily: InterfaceUserFamilyModel; UserInput: UserInput; UserPhone: UserPhone; UserPhoneInput: UserPhoneInput; @@ -2313,6 +2357,7 @@ export type ResolversParentTypes = { UsersConnectionResult: Omit & { data?: Maybe, errors: Array }; createChatInput: CreateChatInput; createGroupChatInput: CreateGroupChatInput; + createUserFamilyInput: CreateUserFamilyInput; }; export type AuthDirectiveArgs = { }; @@ -2691,6 +2736,7 @@ export type MutationResolvers>; addUserImage?: Resolver>; addUserToGroupChat?: Resolver>; + addUserToUserFamily?: Resolver>; adminRemoveEvent?: Resolver>; adminRemoveGroup?: Resolver>; assignUserTag?: Resolver, ParentType, ContextType, RequireFields>; @@ -2713,6 +2759,7 @@ export type MutationResolvers>; createPost?: Resolver, ParentType, ContextType, RequireFields>; createSampleOrganization?: Resolver; + createUserFamily?: Resolver>; createUserTag?: Resolver, ParentType, ContextType, RequireFields>; deleteAdvertisementById?: Resolver>; deleteDonationById?: Resolver>; @@ -2744,7 +2791,9 @@ export type MutationResolvers, ParentType, ContextType, RequireFields>; removeSampleOrganization?: Resolver; removeUserCustomData?: Resolver>; + removeUserFamily?: Resolver>; removeUserFromGroupChat?: Resolver>; + removeUserFromUserFamily?: Resolver>; removeUserImage?: Resolver; removeUserTag?: Resolver, ParentType, ContextType, RequireFields>; revokeRefreshTokenForUser?: Resolver; @@ -3018,6 +3067,15 @@ export type UserEdgeResolvers; }; +export type UserFamilyResolvers = { + _id?: Resolver; + admins?: Resolver, ParentType, ContextType>; + creator?: Resolver; + title?: Resolver, ParentType, ContextType>; + users?: Resolver, ParentType, ContextType>; + __isTypeOf?: IsTypeOfResolverFn; +}; + export type UserPhoneResolvers = { home?: Resolver, ParentType, ContextType>; mobile?: Resolver, ParentType, ContextType>; @@ -3133,6 +3191,7 @@ export type Resolvers = { UserConnection?: UserConnectionResolvers; UserCustomData?: UserCustomDataResolvers; UserEdge?: UserEdgeResolvers; + UserFamily?: UserFamilyResolvers; UserPhone?: UserPhoneResolvers; UserTag?: UserTagResolvers; UserTagEdge?: UserTagEdgeResolvers; diff --git a/src/utilities/userFamilyAdminCheck.ts b/src/utilities/userFamilyAdminCheck.ts new file mode 100644 index 00000000000..a31360d6139 --- /dev/null +++ b/src/utilities/userFamilyAdminCheck.ts @@ -0,0 +1,36 @@ +import { Types } from "mongoose"; +import { errors, requestContext } from "../libraries"; +import { USER_NOT_AUTHORIZED_ADMIN } from "../constants"; +import type { InterfaceUserFamily } from "../models/userFamily"; +import { User } from "../models"; +/** + * If the current user is an admin of the organisation, this function returns `true` otherwise it returns `false`. + * @remarks + * This is a utility method. + * @param userId - Current user id. + * @param userFamily - userFamily data of `InterfaceuserFamily` type. + * @returns `True` or `False`. + */ +export const adminCheck = async ( + userId: string | Types.ObjectId, + userFamily: InterfaceUserFamily, +): Promise => { + const userIsUserFamilyAdmin = userFamily.admins.some( + (admin) => admin === userId || Types.ObjectId(admin).equals(userId), + ); + + const user = await User.findOne({ + _id: userId, + }); + const isUserSuperAdmin: boolean = user + ? user.userType === "SUPERADMIN" + : false; + + if (!userIsUserFamilyAdmin && !isUserSuperAdmin) { + throw new errors.UnauthorizedError( + requestContext.translate(`${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`), + USER_NOT_AUTHORIZED_ADMIN.CODE, + USER_NOT_AUTHORIZED_ADMIN.PARAM, + ); + } +}; diff --git a/tests/helpers/userAndUserFamily.ts b/tests/helpers/userAndUserFamily.ts new file mode 100644 index 00000000000..e4248083040 --- /dev/null +++ b/tests/helpers/userAndUserFamily.ts @@ -0,0 +1,75 @@ +import { nanoid } from "nanoid"; +import type { InterfaceUserFamily } from "../../src/models/userFamily"; +import { User } from "../../src/models"; +import { UserFamily } from "../../src/models/userFamily"; +import type { InterfaceUser } from "../../src/models"; + +import type { Document } from "mongoose"; +/* eslint-disable */ +export type TestUserFamilyType = + | (InterfaceUserFamily & Document) + | null; + +export type TestUserType = + | (InterfaceUser & Document) + | null; +/* eslint-enable */ +export const createTestUserFunc = async (): Promise => { + const testUser = await User.create({ + email: `email${nanoid().toLowerCase()}@gmail.com`, + password: `pass${nanoid().toLowerCase()}`, + firstName: `firstName${nanoid().toLowerCase()}`, + lastName: `lastName${nanoid().toLowerCase()}`, + appLanguageCode: "en", + userType: "SUPERADMIN", + }); + + return testUser; +}; + +export const createTestUserFamilyWithAdmin = async ( + userID: string, + isMember = true, + isAdmin = true, +): Promise => { + const testUser = await createTestUserFunc(); + if (testUser) { + const testUserFamily = await UserFamily.create({ + title: `name${nanoid().toLocaleLowerCase()}`, + users: isMember ? [testUser._id] : [], + admins: isAdmin ? [testUser._id] : [], + creator: [testUser._id], + }); + + await User.updateOne( + { + _id: userID, + }, + { + $push: { + createdUserFamily: testUserFamily._id, + joinedUserFamily: testUserFamily._id, + adminForUserFamily: testUserFamily._id, + }, + }, + ); + + return testUserFamily; + } else { + return null; + } +}; + +export const createTestUserAndUserFamily = async ( + isMember = true, + isAdmin = true, +): Promise<[TestUserType, TestUserFamilyType]> => { + const testUser = await createTestUserFunc(); + const testUserFamily = await createTestUserFamilyWithAdmin( + testUser?._id, + isMember, + isAdmin, + ); + + return [testUser, testUserFamily]; +}; diff --git a/tests/resolvers/Mutation/addUserToUserFamily.spec.ts b/tests/resolvers/Mutation/addUserToUserFamily.spec.ts new file mode 100644 index 00000000000..a29370dece5 --- /dev/null +++ b/tests/resolvers/Mutation/addUserToUserFamily.spec.ts @@ -0,0 +1,154 @@ +import "dotenv/config"; +import type mongoose from "mongoose"; +import { Types } from "mongoose"; +import { UserFamily } from "../../../src/models/userFamily"; +import type { MutationAddUserToUserFamilyArgs } from "../../../src/types/generatedGraphQLTypes"; +import { connect, disconnect } from "../../helpers/db"; + +import { + USER_ALREADY_MEMBER_ERROR, + USER_NOT_FOUND_ERROR, + USER_FAMILY_NOT_FOUND_ERROR, +} from "../../../src/constants"; +import { beforeAll, afterAll, describe, it, expect, vi } from "vitest"; +import type { + TestUserType, + TestUserFamilyType, +} from "../../helpers/userAndUserFamily"; + +import { createTestUserAndUserFamily } from "../../helpers/userAndUserFamily"; + +let testUser: TestUserType; +let testUserFamily: TestUserFamilyType; +let MONGOOSE_INSTANCE: typeof mongoose; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const resultsArray = await createTestUserAndUserFamily(); + testUser = resultsArray[0]; + testUserFamily = resultsArray[1]; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolver -> mutation -> addUserToUserFamily", () => { + afterAll(() => { + vi.doUnmock("../../../src/constants"); + vi.resetModules(); + }); + + it(`throws NotFoundError if no user Family exists with _id === args.familyId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationAddUserToUserFamilyArgs = { + familyId: Types.ObjectId().toString(), + userId: testUser?.id, + }; + + const context = { + userId: testUser?.id, + }; + + const { addUserToUserFamily } = await import( + "../../../src/resolvers/Mutation/addUserToUserFamily" + ); + await addUserToUserFamily?.({}, args, context); + } catch (error) { + expect(spy).toBeCalledWith(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `${USER_FAMILY_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws NotFoundError if no user exists with _id === args.userId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationAddUserToUserFamilyArgs = { + familyId: testUserFamily?._id, + userId: Types.ObjectId().toString(), + }; + + const context = { + userId: testUser?._id, + }; + + const { addUserToUserFamily } = await import( + "../../../src/resolvers/Mutation/addUserToUserFamily" + ); + await addUserToUserFamily?.({}, args, context); + } catch (error) { + expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual(USER_NOT_FOUND_ERROR.MESSAGE); + } + }); + + it(`throws ConflictError if user with _id === args.userId is already a member + of user family group with _id === args.familyId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationAddUserToUserFamilyArgs = { + familyId: testUserFamily?._id, + userId: testUser?.id, + }; + + const context = { + userId: testUser?._id, + }; + + const { addUserToUserFamily } = await import( + "../../../src/resolvers/Mutation/addUserToUserFamily" + ); + await addUserToUserFamily?.({}, args, context); + } catch (error) { + expect(spy).toBeCalledWith(USER_ALREADY_MEMBER_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + USER_ALREADY_MEMBER_ERROR.MESSAGE, + ); + } + }); + + it(`add the user family with _id === args.familyId and returns it`, async () => { + await UserFamily.updateOne( + { + _id: testUserFamily?._id, + }, + { + $set: { + users: [], + }, + }, + ); + + const args: MutationAddUserToUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUser?.id, + }; + + const context = { + userId: testUser?.id, + }; + + const { addUserToUserFamily } = await import( + "../../../src/resolvers/Mutation/addUserToUserFamily" + ); + const addUserToUserFamilyPayload = await addUserToUserFamily?.( + {}, + args, + context, + ); + expect(addUserToUserFamilyPayload?._id).toEqual(testUserFamily?._id); + expect(addUserToUserFamilyPayload?.users).toEqual([testUser?._id]); + }); +}); diff --git a/tests/resolvers/Mutation/createUserFamily.spec.ts b/tests/resolvers/Mutation/createUserFamily.spec.ts new file mode 100644 index 00000000000..38f6dc7d20d --- /dev/null +++ b/tests/resolvers/Mutation/createUserFamily.spec.ts @@ -0,0 +1,189 @@ +import "dotenv/config"; +import type mongoose from "mongoose"; +import { Types } from "mongoose"; +import type { MutationCreateUserFamilyArgs } from "../../../src/types/generatedGraphQLTypes"; +import { connect, disconnect } from "../../helpers/db"; + +import { + LENGTH_VALIDATION_ERROR, + USER_FAMILY_MIN_MEMBERS_ERROR_CODE, + USER_NOT_AUTHORIZED_SUPERADMIN, + USER_NOT_FOUND_ERROR, +} from "../../../src/constants"; +import { beforeAll, afterAll, describe, it, expect, vi } from "vitest"; +import type { TestUserType } from "../../helpers/userAndUserFamily"; +import { createTestUserFunc } from "../../helpers/userAndUserFamily"; +import { createTestUserFunc as createTestUser } from "../../helpers/user"; + +let testUser: TestUserType; +let testUser2: TestUserType; +let MONGOOSE_INSTANCE: typeof mongoose; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const resultsArray = await createTestUserFunc(); + const secondUser = await createTestUser(); + + testUser = resultsArray; + testUser2 = secondUser; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolvers -> Mutation -> createUserFamily", () => { + it(`throws NotFoundError if no user exists with _id === context.userId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + + try { + const args: MutationCreateUserFamilyArgs = { + data: { + title: "title", + userIds: [testUser?._id, testUser2?._id], + }, + }; + + const context = { + userId: Types.ObjectId().toString(), + }; + + const { createUserFamily: createUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/createUserFamily" + ); + + await createUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws Not Authorized error if user is not a super admin`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationCreateUserFamilyArgs = { + data: { + title: "title", + userIds: [testUser?._id, testUser2?._id], + }, + }; + + const context = { + userId: testUser2?._id, + }; + + const { createUserFamily: createUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/createUserFamily" + ); + + await createUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); + expect((error as Error).message).toEqual( + `${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, + ); + } + }); + + it(`throws String Length Validation error if name is greater than 256 characters`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationCreateUserFamilyArgs = { + data: { + title: + "JWQPfpdkGGGKyryb86K4YN85nDj4m4F7gEAMBbMXLax73pn2okV6kpWY0EYO0XSlUc0fAlp45UCgg3s6mqsRYF9FOlzNIDFLZ1rd03Z17cdJRuvBcAmbC0imyqGdXHGDUQmVyOjDkaOLAvjhB5uDeuEqajcAPTcKpZ6LMpigXuqRAd0xGdPNXyITC03FEeKZAjjJL35cSIUeMv5eWmiFlmmm70FU1Bp6575zzBtEdyWPLflcA2GpGmmf4zvT7nfgN3NIkwQIhk9OwP8dn75YYczcYuUzLpxBu1Lyog77YlAj5DNdTIveXu9zHeC6V4EEUcPQtf1622mhdU3jZNMIAyxcAG4ErtztYYRqFs0ApUxXiQI38rmiaLcicYQgcOxpmFvqRGiSduiCprCYm90CHWbQFq4w2uhr8HhR3r9HYMIYtrRyO6C3rPXaQ7otpjuNgE0AKI57AZ4nGG1lvNwptFCY60JEndSLX9Za6XP1zkVRLaMZArQNl", + userIds: [testUser?._id, testUser2?._id], + }, + }; + const context = { + userId: testUser?._id, + }; + + const { createUserFamily: createUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/createUserFamily" + ); + + await createUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith( + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name`, + ); + expect((error as Error).message).toEqual( + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name`, + ); + } + }); + + it(`throws InputValidationError if userIds array has fewer than 2 members`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + try { + const args: MutationCreateUserFamilyArgs = { + data: { + title: "title", + userIds: [testUser?._id], + }, + }; + + const context = { + userId: testUser?.id, + }; + + const { createUserFamily: createUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/createUserFamily" + ); + + await createUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith( + USER_FAMILY_MIN_MEMBERS_ERROR_CODE.MESSAGE, + ); + expect((error as Error).message).toEqual( + `${USER_FAMILY_MIN_MEMBERS_ERROR_CODE.MESSAGE}`, + ); + } + }); + + it(`creates the user Family and returns it`, async () => { + const args: MutationCreateUserFamilyArgs = { + data: { + title: "title", + userIds: [testUser2?._id, testUser?._id], + }, + }; + + const context = { + userId: testUser?.id, + }; + + const { createUserFamily: createUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/createUserFamily" + ); + + const createUserFamilyPayload = await createUserFamilyResolver?.( + {}, + args, + context, + ); + + expect(createUserFamilyPayload).toEqual( + expect.objectContaining({ + title: "title", + }), + ); + }); +}); diff --git a/tests/resolvers/Mutation/removeUserFamily.spec.ts b/tests/resolvers/Mutation/removeUserFamily.spec.ts new file mode 100644 index 00000000000..6af1c377ce4 --- /dev/null +++ b/tests/resolvers/Mutation/removeUserFamily.spec.ts @@ -0,0 +1,139 @@ +import "dotenv/config"; +import type mongoose from "mongoose"; +import { Types } from "mongoose"; +import { UserFamily } from "../../../src/models/userFamily"; +import type { MutationRemoveUserFamilyArgs } from "../../../src/types/generatedGraphQLTypes"; +import { connect, disconnect } from "../../helpers/db"; + +import { + USER_FAMILY_NOT_FOUND_ERROR, + USER_NOT_FOUND_ERROR, +} from "../../../src/constants"; +import { + beforeAll, + afterAll, + describe, + it, + expect, + afterEach, + vi, +} from "vitest"; +import { createTestUserFunc } from "../../helpers/userAndUserFamily"; +import type { + TestUserFamilyType, + TestUserType, +} from "../../helpers/userAndUserFamily"; + +let MONGOOSE_INSTANCE: typeof mongoose; +let testUsers: TestUserType[]; +let testUserFamily: TestUserFamilyType; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const tempUser1 = await createTestUserFunc(); + const tempUser2 = await createTestUserFunc(); + testUsers = [tempUser1, tempUser2]; + + testUserFamily = await UserFamily.create({ + title: "Family", + admins: [tempUser1, tempUser2], + creator: tempUser1, + users: [tempUser1, tempUser2], + }); +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolvers -> Mutation -> removeUserFamily", () => { + afterEach(() => { + vi.resetAllMocks(); + vi.doMock("../../src/constants"); + vi.resetModules(); + }); + + it(`throws NotFoundError if no user exists with _id === context.userId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + + try { + const args: MutationRemoveUserFamilyArgs = { + familyId: testUserFamily?._id, + }; + + const context = { + userId: Types.ObjectId().toString(), + }; + + const { removeUserFamily: removeUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/removeUserFamily" + ); + + await removeUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws NotFoundError if no user family exists with _id === args.familyId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + + try { + const args: MutationRemoveUserFamilyArgs = { + familyId: testUserFamily?._id, + }; + + const context = { + userId: testUsers[1]?._id, + }; + + const { removeUserFamily: removeUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/removeUserFamily" + ); + + await removeUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_FAMILY_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws User is not SUPERADMIN error if current user is with _id === context.userId is not a SUPERADMIN`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => message); + + try { + const args: MutationRemoveUserFamilyArgs = { + familyId: testUserFamily?.id, + }; + + const context = { + userId: testUsers[0]?.id, + }; + + const { removeUserFamily: removeUserFamilyResolver } = await import( + "../../../src/resolvers/Mutation/removeUserFamily" + ); + + await removeUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `${USER_FAMILY_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); +}); diff --git a/tests/resolvers/Mutation/removeUserFromUserFamily.spec.ts b/tests/resolvers/Mutation/removeUserFromUserFamily.spec.ts new file mode 100644 index 00000000000..20a1f367ddd --- /dev/null +++ b/tests/resolvers/Mutation/removeUserFromUserFamily.spec.ts @@ -0,0 +1,289 @@ +import "dotenv/config"; +import type mongoose from "mongoose"; +import { Types } from "mongoose"; +import { UserFamily } from "../../../src/models/userFamily"; +import type { MutationRemoveUserFromUserFamilyArgs } from "../../../src/types/generatedGraphQLTypes"; +import { connect, disconnect } from "../../helpers/db"; + +import { + ADMIN_REMOVING_CREATOR, + USER_FAMILY_NOT_FOUND_ERROR, + USER_NOT_FOUND_ERROR, + USER_REMOVING_SELF, +} from "../../../src/constants"; +import { beforeAll, afterAll, describe, it, expect, vi } from "vitest"; +import { createTestUserFunc } from "../../helpers/userAndUserFamily"; +import type { + TestUserFamilyType, + TestUserType, +} from "../../helpers/userAndUserFamily"; + +let MONGOOSE_INSTANCE: typeof mongoose; +let testUsers: TestUserType[]; +let testUserFamily: TestUserFamilyType; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const tempUser1 = await createTestUserFunc(); + const tempUser2 = await createTestUserFunc(); + const tempUser3 = await createTestUserFunc(); + const tempUser4 = await createTestUserFunc(); + const tempUser5 = await createTestUserFunc(); + testUsers = [tempUser1, tempUser2, tempUser3, tempUser4, tempUser5]; + testUserFamily = await UserFamily.create({ + title: "title", + users: [ + testUsers[0]?._id, + testUsers[1]?._id, + testUsers[2]?._id, + testUsers[4]?._id, + ], + admins: [testUsers[2]?._id, testUsers[1]?._id], + creator: testUsers[2]?._id, + }); +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolver -> Mutation -> removerUserFromUserFamily", () => { + it("should throw user not found error when user with _id === args.userId does not exist", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[4]?._id, + }; + + const context = { + userId: testUsers[1]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws NotFoundError if no user family exists with _id === args.familyId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementationOnce((message) => message); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: Types.ObjectId().toString(), + userId: testUsers[4]?._id, + }; + + const context = { + userId: testUsers[0]?._id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toBeCalledWith(USER_FAMILY_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `${USER_FAMILY_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`throws UnauthorizedError if users field of user family with _id === args.familyId + does not contain user with _id === args.userId`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementationOnce((message) => message); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[3]?._id, + }; + + const context = { + userId: testUsers[2]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it("should throw member not found error when user with _id === args.data.userId does not exist in the user Family", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[3]?._id, + }; + + const context = { + userId: testUsers[2]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it("should throw admin cannot remove self error when user with _id === args.data.userId === context.userId", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[2]?._id, + }; + + const context = { + userId: testUsers[2]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_REMOVING_SELF.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_REMOVING_SELF.MESSAGE}`, + ); + } + }); + + it("should throw admin cannot remove another admin error when user with _id === args.data.userId is also an admin in the user Family", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[1]?._id, + }; + + const context = { + userId: testUsers[2]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it("should throw admin cannot remove creator error when user with _id === args.data.userId is the user Family creator in the user Family", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[2]?._id, + }; + + const context = { + userId: testUsers[1]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + await removeUserFromUserFamilyResolver?.({}, args, context); + } catch (error) { + expect(spy).toHaveBeenCalledWith(ADMIN_REMOVING_CREATOR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${ADMIN_REMOVING_CREATOR.MESSAGE}`, + ); + } + }); + + it("remove that user with _id === args.data.userId from that user Family", async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + try { + const args: MutationRemoveUserFromUserFamilyArgs = { + familyId: testUserFamily?.id, + userId: testUsers[4]?._id, + }; + + const context = { + userId: testUsers[2]?.id, + }; + + const { removeUserFromUserFamily: removeUserFromUserFamilyResolver } = + await import( + "../../../src/resolvers/Mutation/removeUserFromUserFamily" + ); + + const updatedUserFamily = await removeUserFromUserFamilyResolver?.( + {}, + args, + context, + ); + + expect(updatedUserFamily?.users).not.toContain(testUsers[4]?._id); + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); +}); diff --git a/tests/resolvers/UserFamily/admins.spec.ts b/tests/resolvers/UserFamily/admins.spec.ts new file mode 100644 index 00000000000..9e4e92372d1 --- /dev/null +++ b/tests/resolvers/UserFamily/admins.spec.ts @@ -0,0 +1,39 @@ +import "dotenv/config"; +import { admins as usersResolver } from "../../../src/resolvers/UserFamily/admins"; +import { connect, disconnect } from "../../helpers/db"; +import type mongoose from "mongoose"; +import { User } from "../../../src/models"; +import { beforeAll, afterAll, describe, it, expect } from "vitest"; +import type { TestUserFamilyType } from "../../helpers/userAndUserFamily"; +import { createTestUserAndUserFamily } from "../../helpers/userAndUserFamily"; + +let testUserFamily: TestUserFamilyType; +let MONGOOSE_INSTANCE: typeof mongoose; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const resultArray = await createTestUserAndUserFamily(); + testUserFamily = resultArray[1]; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolvers -> UserFamily -> admins", () => { + it(`returns user objects for parent.admins`, async () => { + if (testUserFamily) { + const parent = testUserFamily.toObject(); + + const usersPayload = await usersResolver?.(parent, {}, {}); + + const users = await User.find({ + _id: { + $in: testUserFamily?.admins, + }, + }).lean(); + + expect(usersPayload).toEqual(users); + } + }); +}); diff --git a/tests/resolvers/UserFamily/creator.spec.ts b/tests/resolvers/UserFamily/creator.spec.ts new file mode 100644 index 00000000000..d9a1510459e --- /dev/null +++ b/tests/resolvers/UserFamily/creator.spec.ts @@ -0,0 +1,111 @@ +import "dotenv/config"; +import { connect, disconnect } from "../../helpers/db"; +import type mongoose from "mongoose"; +import { Types } from "mongoose"; +import { User } from "../../../src/models"; +import { UserFamily } from "../../../src/models/userFamily"; + +import { USER_NOT_FOUND_ERROR } from "../../../src/constants"; +import { + beforeAll, + afterAll, + describe, + it, + expect, + afterEach, + vi, +} from "vitest"; +import type { + TestUserType, + TestUserFamilyType, +} from "../../helpers/userAndUserFamily"; +import { createTestUserAndUserFamily } from "../../helpers/userAndUserFamily"; + +let MONGOOSE_INSTANCE: typeof mongoose; +let testUser: TestUserType; +let testUserFamily: TestUserFamilyType; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const userAndUserFamily = await createTestUserAndUserFamily(); + testUser = userAndUserFamily[0]; + testUserFamily = userAndUserFamily[1]; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolvers -> UserFamily -> creator", () => { + afterEach(() => { + vi.doUnmock("../../../src/constants"); + vi.resetModules(); + }); + + it(`throws NotFoundError if no user exists with _id === parent.creator`, async () => { + const { requestContext } = await import("../../../src/libraries"); + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementation((message) => `Translated ${message}`); + + try { + testUserFamily = await UserFamily.findOneAndUpdate( + { + _id: testUserFamily?._id, + }, + { + $set: { + creator: Types.ObjectId().toString(), + }, + }, + { + new: true, + }, + ); + + const parent = testUserFamily?.toObject(); + + const { creator: creatorResolver } = await import( + "../../../src/resolvers/UserFamily/creator" + ); + if (parent) { + await creatorResolver?.(parent, {}, {}); + } + } catch (error) { + expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, + ); + } + }); + + it(`returns user object for parent.creator`, async () => { + testUserFamily = await UserFamily.findOneAndUpdate( + { + _id: testUserFamily?._id, + }, + { + $set: { + creator: testUser?._id, + }, + }, + { + new: true, + }, + ); + + const parent = testUserFamily?.toObject(); + + const { creator: creatorResolver } = await import( + "../../../src/resolvers/UserFamily/creator" + ); + if (parent) { + const creatorPayload = await creatorResolver?.(parent, {}, {}); + const creator = await User.findOne({ + _id: testUserFamily?.creator.toString(), + }).lean(); + + expect(creatorPayload).toEqual(creator); + } + }); +}); diff --git a/tests/resolvers/UserFamily/users.spec.ts b/tests/resolvers/UserFamily/users.spec.ts new file mode 100644 index 00000000000..2654812cf85 --- /dev/null +++ b/tests/resolvers/UserFamily/users.spec.ts @@ -0,0 +1,39 @@ +import "dotenv/config"; +import { users as usersResolver } from "../../../src/resolvers/UserFamily/users"; +import { connect, disconnect } from "../../helpers/db"; +import type mongoose from "mongoose"; +import { User } from "../../../src/models"; +import { beforeAll, afterAll, describe, it, expect } from "vitest"; +import type { TestUserFamilyType } from "../../helpers/userAndUserFamily"; +import { createTestUserAndUserFamily } from "../../helpers/userAndUserFamily"; + +let testUserFamily: TestUserFamilyType; +let MONGOOSE_INSTANCE: typeof mongoose; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const resultArray = await createTestUserAndUserFamily(); + testUserFamily = resultArray[1]; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("resolvers -> UserFamily -> users", () => { + it(`returns user objects for parent.users`, async () => { + if (testUserFamily) { + const parent = testUserFamily.toObject(); + + const usersPayload = await usersResolver?.(parent, {}, {}); + + const users = await User.find({ + _id: { + $in: testUserFamily?.users, + }, + }).lean(); + + expect(usersPayload).toEqual(users); + } + }); +}); diff --git a/tests/utilities/userFamilyAdminCheck.spec.ts b/tests/utilities/userFamilyAdminCheck.spec.ts new file mode 100644 index 00000000000..329ab4de371 --- /dev/null +++ b/tests/utilities/userFamilyAdminCheck.spec.ts @@ -0,0 +1,153 @@ +import "dotenv/config"; +import { + afterAll, + afterEach, + beforeAll, + describe, + expect, + it, + vi, +} from "vitest"; +import { connect, disconnect } from "../helpers/db"; +import { USER_NOT_AUTHORIZED_ADMIN } from "../../src/constants"; +import type { + TestUserFamilyType, + TestUserType, +} from "../helpers/userAndUserFamily"; +import { createTestUserAndUserFamily } from "../helpers/userAndUserFamily"; +import { createTestUserFunc } from "../helpers/user"; +import mongoose from "mongoose"; +import type { InterfaceUserFamily } from "../../src/models/userFamily"; +import { User } from "../../src/models"; +import { UserFamily } from "../../src/models/userFamily"; + +let testUser: TestUserType; +let testUserFamily: TestUserFamilyType; +let MONGOOSE_INSTANCE: typeof mongoose; + +beforeAll(async () => { + MONGOOSE_INSTANCE = await connect(); + const userAndUserFamily = await createTestUserAndUserFamily(false, false); + testUser = await createTestUserFunc(); + testUserFamily = userAndUserFamily[1]; +}); + +afterAll(async () => { + await disconnect(MONGOOSE_INSTANCE); +}); + +describe("utilities -> userFamilyAdminCheck", () => { + afterEach(() => { + vi.resetModules(); + }); + + it("throws error if userIsUserFamilyAdmin === false and isUserSuperAdmin === false", async () => { + const { requestContext } = await import("../../src/libraries"); + + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementationOnce((message) => `Translated ${message}`); + + try { + const { adminCheck } = await import( + "../../src/utilities/userFamilyAdminCheck" + ); + await adminCheck( + testUser?._id, + testUserFamily ?? ({} as InterfaceUserFamily), + ); + } catch (error) { + expect(error).toEqual(`Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`); + } + expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); + }); + + it("throws no error if userIsUserFamilyAdmin === false and isUserSuperAdmin === true", async () => { + const updatedUser = await User.findOneAndUpdate( + { + _id: testUser?._id, + }, + { + userType: "SUPERADMIN", + }, + { + new: true, + upsert: true, + }, + ); + + const { adminCheck } = await import( + "../../src/utilities/userFamilyAdminCheck" + ); + + await expect( + adminCheck( + updatedUser?._id, + testUserFamily ?? ({} as InterfaceUserFamily), + ), + ).resolves.not.toThrowError(); + }); + + it("throws no error if user is an admin in that user family but not super admin", async () => { + const updatedUser = await User.findOneAndUpdate( + { + _id: testUser?._id, + }, + { + userType: "USER", + }, + { + new: true, + upsert: true, + }, + ); + + const updatedUserFamily = await UserFamily.findOneAndUpdate( + { + _id: testUserFamily?._id, + }, + { + $push: { + admins: testUser?._id, + }, + }, + { + new: true, + upsert: true, + }, + ); + + const { adminCheck } = await import( + "../../src/utilities/userFamilyAdminCheck" + ); + + await expect( + adminCheck( + updatedUser?._id, + updatedUserFamily ?? ({} as InterfaceUserFamily), + ), + ).resolves.not.toThrowError(); + }); + it("throws error if user is not found with the specific Id", async () => { + const { requestContext } = await import("../../src/libraries"); + + const spy = vi + .spyOn(requestContext, "translate") + .mockImplementationOnce((message) => `Translated ${message}`); + + try { + const { adminCheck } = await import( + "../../src/utilities/userFamilyAdminCheck" + ); + await adminCheck( + new mongoose.Types.ObjectId(), + testUserFamily ?? ({} as InterfaceUserFamily), + ); + } catch (error) { + expect((error as Error).message).toEqual( + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, + ); + } + expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); + }); +}); From 90539cfb2cc3933306dd6b18114e4e3351612894 Mon Sep 17 00:00:00 2001 From: aditya Date: Wed, 7 Feb 2024 18:49:09 +0530 Subject: [PATCH 2/4] new commit --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bdacd57db57..327fa7941ae 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,11 @@ Core features include: -- [Talawa Components](#talawa-components) -- [Documentation](#documentation) -- [Installation](#installation) -- [Image Upload](#image-upload) +- [Talawa API](#talawa-api) + - [Talawa Components](#talawa-components) + - [Documentation](#documentation) + - [Installation](#installation) + - [Image Upload](#image-upload) @@ -52,4 +53,4 @@ Core features include: ## Image Upload -To enable image upload functionalities create an images folder in the root of the project +To enable image upload functionalities create an images folder in the root of the project \ No newline at end of file From 92038f0d908446946f27378beff98e43374d298f Mon Sep 17 00:00:00 2001 From: aditya Date: Wed, 7 Feb 2024 19:01:12 +0530 Subject: [PATCH 3/4] new commit --- .github/workflows/pull-request.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 910c382939a..aa28f3dfb11 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -64,7 +64,9 @@ jobs: run: npx eslint ${CHANGED_FILES} - name: Check for formatting errors - run: npm run format:check + env: + CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} + run: npm run format:check ${CHANGED_FILES} - name: Run Typescript Type-Checker run: npm run typecheck From 7b20db603b4b9ae9de7ccfee61e58518f3c4196e Mon Sep 17 00:00:00 2001 From: aditya Date: Wed, 7 Feb 2024 19:03:41 +0530 Subject: [PATCH 4/4] new commit --- setup.ts | 44 +++++++++---------- src/app.ts | 8 ++-- src/checks.ts | 8 ++-- src/config/plugins/loadPlugins.ts | 4 +- src/db.ts | 10 ++--- .../authDirectiveTransformer.ts | 6 +-- .../roleDirectiveTransformer.ts | 10 ++--- src/helpers/eventInstances/once.ts | 4 +- src/helpers/eventInstances/weekly.ts | 4 +- src/index.ts | 12 ++--- src/libraries/dbLogger.ts | 4 +- .../errors/ImageSizeLimitExceeded.ts | 2 +- src/libraries/errors/conflictError.ts | 2 +- src/libraries/errors/inputValidationError.ts | 2 +- src/libraries/errors/internalServerError.ts | 2 +- src/libraries/errors/invalidFileTypeError.ts | 2 +- src/libraries/errors/notFoundError.ts | 2 +- src/libraries/errors/unauthenticatedError.ts | 2 +- src/libraries/errors/unauthorizedError.ts | 2 +- src/libraries/logger.ts | 12 ++--- src/libraries/requestContext.ts | 2 +- src/libraries/requestTracing.ts | 2 +- .../validators/validatePaginationArgs.ts | 2 +- src/libraries/validators/validateString.ts | 2 +- src/middleware/isAuth.ts | 2 +- src/models/ActionItem.ts | 2 +- src/models/ActionItemCategory.ts | 6 +-- src/models/Advertisement.ts | 2 +- src/models/CheckIn.ts | 2 +- src/models/Comment.ts | 2 +- src/models/DirectChat.ts | 2 +- src/models/DirectChatMessage.ts | 4 +- src/models/Donation.ts | 2 +- src/models/Event.ts | 2 +- src/models/Feedback.ts | 2 +- src/models/File.ts | 2 +- src/models/Group.ts | 2 +- src/models/GroupChat.ts | 2 +- src/models/GroupChatMessage.ts | 2 +- src/models/MembershipRequest.ts | 2 +- src/models/Message.ts | 2 +- src/models/MessageChat.ts | 2 +- src/models/Organization.ts | 2 +- src/models/OrganizationCustomField.ts | 2 +- src/models/OrganizationTagUser.ts | 4 +- src/models/Post.ts | 2 +- src/resolvers/ActionItemCategory/creator.ts | 2 +- .../ActionItemCategory/organization.ts | 2 +- src/resolvers/DirectChat/organization.ts | 2 +- src/resolvers/DirectChatMessage/receiver.ts | 2 +- src/resolvers/Event/attendees.ts | 2 +- src/resolvers/Event/averageFeedbackScore.ts | 2 +- src/resolvers/GroupChat/organization.ts | 2 +- .../MembershipRequest/organization.ts | 2 +- src/resolvers/Mutation/acceptAdmin.ts | 8 ++-- .../Mutation/acceptMembershipRequest.ts | 14 +++--- src/resolvers/Mutation/addEventAttendee.ts | 14 +++--- src/resolvers/Mutation/addFeedback.ts | 10 ++--- .../Mutation/addLanguageTranslation.ts | 4 +- .../Mutation/addOrganizationCustomField.ts | 14 +++--- .../Mutation/addOrganizationImage.ts | 6 +-- src/resolvers/Mutation/addUserCustomData.ts | 6 +-- src/resolvers/Mutation/addUserImage.ts | 8 ++-- src/resolvers/Mutation/addUserToGroupChat.ts | 12 ++--- src/resolvers/Mutation/adminRemoveEvent.ts | 10 ++--- src/resolvers/Mutation/adminRemoveGroup.ts | 8 ++-- src/resolvers/Mutation/assignUserTag.ts | 20 ++++----- .../blockPluginCreationBySuperadmin.ts | 4 +- src/resolvers/Mutation/blockUser.ts | 20 ++++----- .../Mutation/cancelMembershipRequest.ts | 14 +++--- src/resolvers/Mutation/checkIn.ts | 18 ++++---- src/resolvers/Mutation/createActionItem.ts | 21 ++++----- .../Mutation/createActionItemCategory.ts | 6 +-- src/resolvers/Mutation/createAdmin.ts | 20 ++++----- src/resolvers/Mutation/createComment.ts | 6 +-- src/resolvers/Mutation/createDirectChat.ts | 6 +-- src/resolvers/Mutation/createDonation.ts | 2 +- src/resolvers/Mutation/createEvent.ts | 42 +++++++++--------- src/resolvers/Mutation/createGroupChat.ts | 6 +-- src/resolvers/Mutation/createMember.ts | 16 +++---- src/resolvers/Mutation/createMessageChat.ts | 4 +- src/resolvers/Mutation/createOrganization.ts | 10 ++--- src/resolvers/Mutation/createPlugin.ts | 2 +- src/resolvers/Mutation/createPost.ts | 24 +++++----- .../Mutation/createSampleOrganization.ts | 6 +-- src/resolvers/Mutation/createUserTag.ts | 16 +++---- src/resolvers/Mutation/forgotPassword.ts | 4 +- .../Mutation/joinPublicOrganization.ts | 14 +++--- src/resolvers/Mutation/leaveOrganization.ts | 14 +++--- src/resolvers/Mutation/likeComment.ts | 8 ++-- src/resolvers/Mutation/likePost.ts | 8 ++-- src/resolvers/Mutation/login.ts | 10 ++--- src/resolvers/Mutation/logout.ts | 4 +- src/resolvers/Mutation/otp.ts | 2 +- src/resolvers/Mutation/recaptcha.ts | 4 +- src/resolvers/Mutation/refreshToken.ts | 14 +++--- src/resolvers/Mutation/registerForEvent.ts | 8 ++-- src/resolvers/Mutation/rejectAdmin.ts | 8 ++-- .../Mutation/rejectMembershipRequest.ts | 10 ++--- src/resolvers/Mutation/removeActionItem.ts | 17 +++---- src/resolvers/Mutation/removeAdmin.ts | 18 ++++---- src/resolvers/Mutation/removeAdvertisement.ts | 2 +- src/resolvers/Mutation/removeComment.ts | 12 ++--- src/resolvers/Mutation/removeDirectChat.ts | 6 +-- src/resolvers/Mutation/removeEvent.ts | 18 ++++---- src/resolvers/Mutation/removeEventAttendee.ts | 12 ++--- src/resolvers/Mutation/removeGroupChat.ts | 6 +-- src/resolvers/Mutation/removeMember.ts | 26 +++++------ src/resolvers/Mutation/removeOrganization.ts | 16 +++---- .../Mutation/removeOrganizationCustomField.ts | 17 ++++--- .../Mutation/removeOrganizationImage.ts | 6 +-- src/resolvers/Mutation/removePost.ts | 12 ++--- .../Mutation/removeSampleOrganization.ts | 6 +-- .../Mutation/removeUserCustomData.ts | 10 ++--- .../Mutation/removeUserFromGroupChat.ts | 12 ++--- src/resolvers/Mutation/removeUserImage.ts | 8 ++-- src/resolvers/Mutation/removeUserTag.ts | 12 ++--- .../Mutation/revokeRefreshTokenForUser.ts | 2 +- src/resolvers/Mutation/saveFcmToken.ts | 4 +- .../Mutation/sendMembershipRequest.ts | 8 ++-- .../Mutation/sendMessageToDirectChat.ts | 8 ++-- .../Mutation/sendMessageToGroupChat.ts | 10 ++--- src/resolvers/Mutation/signUp.ts | 4 +- src/resolvers/Mutation/togglePostPin.ts | 26 +++++------ src/resolvers/Mutation/unassignUserTag.ts | 14 +++--- src/resolvers/Mutation/unblockUser.ts | 20 ++++----- src/resolvers/Mutation/unlikeComment.ts | 8 ++-- src/resolvers/Mutation/unlikePost.ts | 8 ++-- .../Mutation/unregisterForEventByUser.ts | 4 +- src/resolvers/Mutation/updateActionItem.ts | 27 ++++++------ .../Mutation/updateActionItemCategory.ts | 6 +-- src/resolvers/Mutation/updateAdvertisement.ts | 16 +++---- src/resolvers/Mutation/updateEvent.ts | 26 +++++------ src/resolvers/Mutation/updateLanguage.ts | 4 +- src/resolvers/Mutation/updateOrganization.ts | 6 +-- src/resolvers/Mutation/updatePluginStatus.ts | 6 +-- src/resolvers/Mutation/updatePost.ts | 24 +++++----- src/resolvers/Mutation/updateUserPassword.ts | 14 +++--- src/resolvers/Mutation/updateUserProfile.ts | 10 ++--- .../Mutation/updateUserRoleInOrganization.ts | 28 ++++++------ src/resolvers/Mutation/updateUserTag.ts | 16 +++---- src/resolvers/Mutation/updateUserType.ts | 10 ++--- src/resolvers/Organization/blockedUsers.ts | 2 +- src/resolvers/Organization/creator.ts | 2 +- src/resolvers/Organization/image.ts | 2 +- src/resolvers/Organization/pinnedPosts.ts | 2 +- src/resolvers/Query/actionItem.ts | 4 +- src/resolvers/Query/actionItemCategory.ts | 4 +- src/resolvers/Query/actionItemsByEvent.ts | 2 +- .../Query/actionItemsByOrganization.ts | 2 +- src/resolvers/Query/checkAuth.ts | 4 +- .../Query/customFieldsByOrganization.ts | 2 +- src/resolvers/Query/directChatsByUserID.ts | 2 +- .../Query/directChatsMessagesByChatID.ts | 2 +- src/resolvers/Query/event.ts | 2 +- src/resolvers/Query/getDonationById.ts | 2 +- src/resolvers/Query/getDonationByOrgId.ts | 2 +- src/resolvers/Query/getlanguage.ts | 2 +- src/resolvers/Query/hasSubmittedFeedback.ts | 8 ++-- .../Query/helperFunctions/getSort.ts | 2 +- .../Query/helperFunctions/getWhere.ts | 2 +- src/resolvers/Query/me.ts | 2 +- src/resolvers/Query/myLanguage.ts | 4 +- src/resolvers/Query/organizationIsSample.ts | 2 +- src/resolvers/Query/organizations.ts | 4 +- .../Query/organizationsMemberConnection.ts | 2 +- src/resolvers/Query/post.ts | 2 +- .../Query/postsByOrganizationConnection.ts | 2 +- src/resolvers/Query/user.ts | 2 +- src/resolvers/Query/userLanguage.ts | 4 +- src/resolvers/Query/users.ts | 4 +- src/resolvers/Query/usersConnection.ts | 2 +- .../Subscription/directMessageChat.ts | 2 +- .../Subscription/messageSentToDirectChat.ts | 2 +- .../Subscription/messageSentToGroupChat.ts | 6 +-- src/resolvers/Subscription/onPluginUpdate.ts | 4 +- src/resolvers/UserTag/childTags.ts | 4 +- src/resolvers/UserTag/organization.ts | 2 +- src/resolvers/UserTag/usersAssignedTo.ts | 6 +-- src/resolvers/middleware/currentUserExists.ts | 2 +- src/services/CommentCache/cacheComments.ts | 2 +- .../CommentCache/deleteCommentFromCache.ts | 2 +- .../findCommentsByPostIdInCache.ts | 2 +- .../CommentCache/findCommentsInCache.ts | 2 +- .../EventCache/deleteEventFromCache.ts | 2 +- src/services/EventCache/findEventInCache.ts | 2 +- .../OrganizationCache/cacheOrganizations.ts | 2 +- .../deleteOrganizationFromCache.ts | 2 +- .../findOrganizationsInCache.ts | 4 +- src/services/PostCache/findPostsInCache.ts | 2 +- src/utilities/PII/decryption.ts | 4 +- src/utilities/PII/encryption.ts | 2 +- src/utilities/PII/isAuthorised.ts | 2 +- src/utilities/adminCheck.ts | 6 +-- src/utilities/auth.ts | 4 +- src/utilities/createSampleOrganizationUtil.ts | 20 ++++----- src/utilities/deleteImage.ts | 6 +-- .../deletePreviousImage.ts | 4 +- .../encodedImageExtensionCheck.ts | 2 +- .../encodedImageStorage/uploadEncodedImage.ts | 8 ++-- .../deletePreviousVideo.ts | 4 +- .../encodedVideoExtensionCheck.ts | 2 +- .../encodedVideoStorage/uploadEncodedVideo.ts | 6 +-- src/utilities/graphqlConnectionFactory.ts | 8 ++-- src/utilities/imageAlreadyInDbCheck.ts | 8 ++-- src/utilities/imageExtensionCheck.ts | 2 +- src/utilities/loadSampleData.ts | 2 +- src/utilities/mailer.ts | 4 +- src/utilities/reuploadDuplicateCheck.ts | 4 +- src/utilities/superAdminCheck.ts | 2 +- src/utilities/uploadImage.ts | 12 ++--- .../authDirectiveTransformer.spec.ts | 8 ++-- .../roleDirectiveTransformer.spec.ts | 8 ++-- tests/helpers/actionItem.ts | 6 +-- tests/helpers/advertisement.ts | 2 +- tests/helpers/checkIn.ts | 2 +- tests/helpers/db.ts | 8 ++-- tests/helpers/directChat.ts | 8 ++-- tests/helpers/donation.ts | 2 +- tests/helpers/events.ts | 6 +-- tests/helpers/eventsWithRegistrants.ts | 4 +- tests/helpers/feedback.ts | 4 +- tests/helpers/groupChat.ts | 2 +- tests/helpers/membershipRequests.ts | 8 ++-- tests/helpers/posts.ts | 14 +++--- tests/helpers/tags.ts | 8 ++-- tests/helpers/userAndOrg.ts | 12 ++--- tests/libraries/dbLogger.spec.ts | 8 ++-- .../errors/internalServerError.spec.ts | 2 +- .../errors/unauthenticatedError.spec.ts | 2 +- tests/libraries/logger.spec.ts | 4 +- tests/libraries/requestContext.spec.ts | 6 +-- tests/libraries/requestTracing.spec.ts | 4 +- tests/middleware/isAuth.spec.ts | 6 +-- tests/resolvers/ActionItem/category.spec.ts | 2 +- tests/resolvers/ActionItem/event.spec.ts | 4 +- .../directChatMessageBelongsTo.spec.ts | 2 +- .../Event/averageFeedbackScore.test.ts | 4 +- tests/resolvers/GroupChat/creator.spec.ts | 2 +- tests/resolvers/Mutation/acceptAdmin.spec.ts | 8 ++-- .../Mutation/acceptMembershipRequest.spec.ts | 30 ++++++------- .../Mutation/addEventAttendee.spec.ts | 12 ++--- tests/resolvers/Mutation/addFeedback.spec.ts | 10 ++--- .../Mutation/addLanguageTranslation.spec.ts | 4 +- .../addOrganizationCustomField.spec.ts | 16 +++---- .../Mutation/addOrganizationImage.spec.ts | 6 +-- .../Mutation/addUserCustomData.spec.ts | 8 ++-- tests/resolvers/Mutation/addUserImage.spec.ts | 6 +-- .../Mutation/addUserToGroupChat.spec.ts | 14 +++--- .../Mutation/adminRemoveEvent.spec.ts | 16 +++---- .../Mutation/adminRemoveGroup.spec.ts | 14 +++--- .../resolvers/Mutation/assignUserTag.spec.ts | 14 +++--- .../blockPluginCreationBySuperadmin.spec.ts | 6 +-- tests/resolvers/Mutation/blockUser.spec.ts | 16 +++---- .../Mutation/cancelMembershipRequest.spec.ts | 12 ++--- tests/resolvers/Mutation/checkIn.spec.ts | 14 +++--- .../Mutation/createActionItem.spec.ts | 20 ++++----- .../Mutation/createActionItemCategory.spec.ts | 14 +++--- tests/resolvers/Mutation/createAdmin.spec.ts | 14 +++--- .../Mutation/createAdvertisement.spec.ts | 4 +- .../resolvers/Mutation/createComment.spec.ts | 8 ++-- .../Mutation/createDirectChat.spec.ts | 4 +- .../resolvers/Mutation/createDonation.spec.ts | 2 +- tests/resolvers/Mutation/createEvent.spec.ts | 40 ++++++++--------- .../Mutation/createGroupChat.spec.ts | 6 +-- tests/resolvers/Mutation/createMember.spec.ts | 12 ++--- .../Mutation/createMessageChat.spec.ts | 8 ++-- .../Mutation/createOrganization.spec.ts | 36 +++++++-------- tests/resolvers/Mutation/createPlugin.spec.ts | 2 +- tests/resolvers/Mutation/createPost.spec.ts | 32 +++++++------- .../Mutation/createSampleOrganization.spec.ts | 16 +++---- .../resolvers/Mutation/createUserTag.spec.ts | 12 ++--- .../Mutation/deleteAdvertisementById.spec.ts | 4 +- .../Mutation/deleteDonationById.spec.ts | 4 +- .../resolvers/Mutation/forgotPassword.spec.ts | 4 +- .../Mutation/getAdvertisement.spec.ts | 8 ++-- .../Mutation/joinPublicOrganization.spec.ts | 4 +- .../Mutation/leaveOrganization.spec.ts | 6 +-- tests/resolvers/Mutation/likeComment.spec.ts | 2 +- tests/resolvers/Mutation/login.spec.ts | 12 ++--- tests/resolvers/Mutation/otp.spec.ts | 2 +- tests/resolvers/Mutation/refreshToken.spec.ts | 22 +++++----- .../Mutation/registerForEvent.spec.ts | 4 +- tests/resolvers/Mutation/rejectAdmin.spec.ts | 6 +-- .../Mutation/rejectMembershipRequest.spec.ts | 18 ++++---- .../Mutation/removeActionItem.spec.ts | 20 ++++----- tests/resolvers/Mutation/removeAdmin.spec.ts | 14 +++--- .../Mutation/removeAdvertisement.spec.ts | 12 ++--- .../resolvers/Mutation/removeComment.spec.ts | 12 ++--- .../Mutation/removeDirectChat.spec.ts | 14 +++--- tests/resolvers/Mutation/removeEvent.spec.ts | 8 ++-- .../Mutation/removeEventAttendee.spec.ts | 12 ++--- .../Mutation/removeGroupChat.spec.ts | 18 ++++---- tests/resolvers/Mutation/removeMember.spec.ts | 22 +++++----- .../Mutation/removeOrganization.spec.ts | 26 +++++------ .../removeOrganizationCustomField.spec.ts | 26 +++++------ .../Mutation/removeOrganizationImage.spec.ts | 14 +++--- tests/resolvers/Mutation/removePost.spec.ts | 22 +++++----- .../Mutation/removeSampleOrganization.spec.ts | 20 ++++----- .../Mutation/removeUserCustomData.spec.ts | 26 +++++------ .../Mutation/removeUserFromGroupChat.spec.ts | 12 ++--- .../Mutation/removeUserImage.spec.ts | 8 ++-- .../resolvers/Mutation/removeUserTag.spec.ts | 6 +-- .../Mutation/sendMembershipRequest.spec.ts | 8 ++-- .../Mutation/sendMessageToDirectChat.spec.ts | 8 ++-- .../Mutation/sendMessageToGroupChat.spec.ts | 6 +-- tests/resolvers/Mutation/signUp.spec.ts | 2 +- .../resolvers/Mutation/togglePostPin.spec.ts | 24 +++++----- .../Mutation/unassignUserTag.spec.ts | 14 +++--- tests/resolvers/Mutation/unblockUser.spec.ts | 8 ++-- .../resolvers/Mutation/unlikeComment.spec.ts | 6 +-- .../Mutation/unregisterForEventByUser.spec.ts | 6 +-- .../Mutation/updateActionItem.spec.ts | 22 +++++----- .../Mutation/updateActionItemCategory.spec.ts | 14 +++--- .../Mutation/updateAdvertisement.spec.ts | 18 ++++---- tests/resolvers/Mutation/updateEvent.spec.ts | 26 +++++------ .../resolvers/Mutation/updateLanguage.spec.ts | 2 +- .../Mutation/updateOrganization.spec.ts | 18 ++++---- .../Mutation/updatePluginStatus.spec.ts | 4 +- tests/resolvers/Mutation/updatePost.spec.ts | 18 ++++---- .../Mutation/updateUserPassword.spec.ts | 10 ++--- .../Mutation/updateUserProfile.spec.ts | 26 +++++------ .../updateUserRoleInOrganization.spec.ts | 36 +++++++-------- .../resolvers/Mutation/updateUserTag.spec.ts | 8 ++-- .../resolvers/Mutation/updateUserType.spec.ts | 16 +++---- .../Organization/actionItemCategories.spec.ts | 2 +- tests/resolvers/Organization/creator.spec.ts | 6 +-- tests/resolvers/Organization/image.spec.ts | 4 +- .../Organization/membershipRequests.spec.ts | 6 +-- .../Organization/pinnedPosts.spec.ts | 2 +- tests/resolvers/Post/comments.spec.ts | 6 +-- tests/resolvers/Query/actionItem.spec.ts | 2 +- ...actionItemCategoriesByOrganization.spec.ts | 2 +- .../Query/actionItemCategory.spec.ts | 4 +- .../Query/actionItemsByEvent.spec.ts | 2 +- .../Query/actionItemsByOrganization.spec.ts | 4 +- tests/resolvers/Query/checkAuth.spec.ts | 2 +- .../Query/customDataByOrganization.spec.ts | 2 +- .../Query/customFieldsByOrganization.spec.ts | 8 ++-- .../Query/directChatsByUserID.spec.ts | 2 +- .../Query/directChatsMessagesByChatID.spec.ts | 8 ++-- .../Query/eventsByOrganization.spec.ts | 6 +-- .../eventsByOrganizationConnection.spec.ts | 6 +-- tests/resolvers/Query/getDonationById.spec.ts | 4 +- .../Query/getDonationByOrgId.spec.ts | 2 +- .../getDonationByOrgIdConnection.spec.ts | 22 +++++----- tests/resolvers/Query/getlanguage.spec.ts | 2 +- .../Query/hasSubmittedFeedback.spec.ts | 10 ++--- .../Query/organizationIsSample.spec.ts | 6 +-- .../Query/organizationsConnection.spec.ts | 2 +- .../organizationsMemberConnection.spec.ts | 12 ++--- .../Query/postsByOrganization.spec.ts | 38 ++++++++-------- .../postsByOrganizationConnection.spec.ts | 2 +- tests/resolvers/Query/user.spec.ts | 2 +- tests/resolvers/Query/users.spec.ts | 10 ++--- tests/resolvers/Query/usersConnection.spec.ts | 26 +++++------ .../messageSentToDirectChat.spec.ts | 4 +- tests/resolvers/UserTag/childTags.spec.ts | 6 +-- .../resolvers/UserTag/usersAssignedTo.spec.ts | 6 +-- .../middleware/currentUserExists.spec.ts | 2 +- tests/utilities/adminCheck.spec.ts | 22 +++++----- tests/utilities/auth.spec.ts | 20 ++++----- .../createSampleOrganizationUtil.spec.ts | 4 +- tests/utilities/deleteDuplicatedImage.spec.ts | 6 +-- tests/utilities/deleteImage.spec.ts | 20 ++++----- .../graphqlConnectionFactory.spec.ts | 16 +++---- tests/utilities/imageAlreadyInDbCheck.spec.ts | 4 +- tests/utilities/mailer.spec.ts | 4 +- .../utilities/reuploadDuplicateCheck.spec.ts | 4 +- tests/utilities/superAdminCheck.spec.ts | 2 +- tests/utilities/uploadImage.spec.ts | 30 ++++++------- 371 files changed, 1553 insertions(+), 1551 deletions(-) diff --git a/setup.ts b/setup.ts index 035fbbf3498..ab1c39481e7 100644 --- a/setup.ts +++ b/setup.ts @@ -100,7 +100,7 @@ async function setNodeEnvironment(): Promise { */ async function accessAndRefreshTokens( accessTokenSecret: string | null, - refreshTokenSecret: string | null + refreshTokenSecret: string | null, ): Promise { const config = dotenv.parse(fs.readFileSync(".env")); @@ -183,12 +183,12 @@ async function askForTransactionLogPath(): Promise { break; } catch { console.error( - "The file is not readable/writable. Please enter a valid file path." + "The file is not readable/writable. Please enter a valid file path.", ); } } else { console.error( - "Invalid path or file does not exist. Please enter a valid file path." + "Invalid path or file does not exist. Please enter a valid file path.", ); } } @@ -350,7 +350,7 @@ async function redisConfiguration(): Promise { */ async function askForSuperAdminEmail(): Promise { console.log( - "\nPlease make sure to register with this email before logging in.\n" + "\nPlease make sure to register with this email before logging in.\n", ); const { email } = await inquirer.prompt([ { @@ -558,7 +558,7 @@ async function recaptcha(): Promise { async function recaptchaSiteKey(): Promise { if (process.env.RECAPTCHA_SITE_KEY) { console.log( - `\nreCAPTCHA site key already exists with the value ${process.env.RECAPTCHA_SITE_KEY}` + `\nreCAPTCHA site key already exists with the value ${process.env.RECAPTCHA_SITE_KEY}`, ); } @@ -636,14 +636,14 @@ function abort(): void { async function twoFactorAuth(): Promise { console.log("\nIMPORTANT"); console.log( - "\nEnsure that you have Two-Factor Authentication set up on your Google Account." + "\nEnsure that you have Two-Factor Authentication set up on your Google Account.", ); console.log("\nVisit Url: https://myaccount.google.com"); console.log( - "\nSelect Security and under Signing in to Google section select App Passwords." + "\nSelect Security and under Signing in to Google section select App Passwords.", ); console.log( - "\nClick on Select app section and choose Other(Custom name), enter talawa as the custom name and press Generate button." + "\nClick on Select app section and choose Other(Custom name), enter talawa as the custom name and press Generate button.", ); const { email, password } = await inquirer.prompt([ @@ -741,7 +741,7 @@ async function importData(): Promise { abort(); } console.log(`Output: ${stdout}`); - } + }, ); } } @@ -762,7 +762,7 @@ type VerifySmtpConnectionReturnType = { * be `true` and the `error` property will be `null`. If the SMTP connection verification fails */ async function verifySmtpConnection( - config: Record + config: Record, ): Promise { const transporter = nodemailer.createTransport({ host: config.SMTP_HOST, @@ -829,7 +829,7 @@ async function configureSmtp(): Promise { if (!isValidSmtpConfig) { console.error( - "Invalid SMTP configuration. Please provide all required parameters." + "Invalid SMTP configuration. Please provide all required parameters.", ); return; } @@ -838,7 +838,7 @@ async function configureSmtp(): Promise { if (!success) { console.error( - "SMTP configuration verification failed. Please check your SMTP settings." + "SMTP configuration verification failed. Please check your SMTP settings.", ); if (error instanceof Error) { console.log(error.message); @@ -876,7 +876,7 @@ async function main(): Promise { refreshToken: string | null = ""; if (process.env.ACCESS_TOKEN_SECRET) { console.log( - `\nAccess token secret already exists with the value:\n${process.env.ACCESS_TOKEN_SECRET}` + `\nAccess token secret already exists with the value:\n${process.env.ACCESS_TOKEN_SECRET}`, ); } const { shouldGenerateAccessToken } = await inquirer.prompt({ @@ -892,7 +892,7 @@ async function main(): Promise { if (process.env.REFRESH_TOKEN_SECRET) { console.log( - `\nRefresh token secret already exists with the value:\n${process.env.REFRESH_TOKEN_SECRET}` + `\nRefresh token secret already exists with the value:\n${process.env.REFRESH_TOKEN_SECRET}`, ); } const { shouldGenerateRefreshToken } = await inquirer.prompt({ @@ -918,7 +918,7 @@ async function main(): Promise { if (shouldLog) { if (process.env.LOG_PATH) { console.log( - `\n Log path already exists with the value:\n${process.env.LOG_PATH}` + `\n Log path already exists with the value:\n${process.env.LOG_PATH}`, ); } let logPath: string | null = null; @@ -997,7 +997,7 @@ async function main(): Promise { // MongoDB configuration if (process.env.MONGO_DB_URL) { console.log( - `\nMongoDB URL already exists with the value:\n${process.env.MONGO_DB_URL}` + `\nMongoDB URL already exists with the value:\n${process.env.MONGO_DB_URL}`, ); const { shouldSetupMongo } = await inquirer.prompt({ @@ -1016,7 +1016,7 @@ async function main(): Promise { } if (process.env.RECAPTCHA_SECRET_KEY) { console.log( - `\nreCAPTCHA secret key already exists with the value ${process.env.RECAPTCHA_SECRET_KEY}` + `\nreCAPTCHA secret key already exists with the value ${process.env.RECAPTCHA_SECRET_KEY}`, ); } const { shouldSetRecaptcha } = await inquirer.prompt({ @@ -1032,12 +1032,12 @@ async function main(): Promise { } console.log( - "\n You can configure either SMTP or Mail for sending emails through Talawa.\n" + "\n You can configure either SMTP or Mail for sending emails through Talawa.\n", ); if (process.env.MAIL_USERNAME) { console.log( - `Mail username already exists with the value ${process.env.MAIL_USERNAME}` + `Mail username already exists with the value ${process.env.MAIL_USERNAME}`, ); } @@ -1070,7 +1070,7 @@ async function main(): Promise { if (process.env.LAST_RESORT_SUPERADMIN_EMAIL) { console.log( - `\nSuper Admin of last resort already exists with the value ${process.env.LAST_RESORT_SUPERADMIN_EMAIL}` + `\nSuper Admin of last resort already exists with the value ${process.env.LAST_RESORT_SUPERADMIN_EMAIL}`, ); } @@ -1093,7 +1093,7 @@ async function main(): Promise { ) { if (process.env.MAIL_USERNAME) { console.log( - "No super admin email configured, setting it to mail username's value." + "No super admin email configured, setting it to mail username's value.", ); } const config = dotenv.parse(fs.readFileSync(".env")); @@ -1135,7 +1135,7 @@ async function main(): Promise { await setImageUploadSize(imageSizeLimit * 1000); console.log( - "\nCongratulations! Talawa API has been successfully setup! 🥂🎉" + "\nCongratulations! Talawa API has been successfully setup! 🥂🎉", ); } diff --git a/src/app.ts b/src/app.ts index e26d89fda33..7a333538301 100644 --- a/src/app.ts +++ b/src/app.ts @@ -61,7 +61,7 @@ app.use( helmet({ contentSecurityPolicy: process.env.NODE_ENV === "production" ? undefined : false, - }) + }), ); app.use(mongoSanitize()); app.use(cors()); @@ -81,8 +81,8 @@ app.use( ':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] :response-time ms', { stream: stream, - } - ) + }, + ), ); app.use("/images", express.static(path.join(__dirname, "./../images"))); @@ -97,7 +97,7 @@ app.get("/", (req, res) => res.json({ "talawa-version": "v1", status: "healthy", - }) + }), ); export default app; diff --git a/src/checks.ts b/src/checks.ts index 41147f27813..0e97e688027 100644 --- a/src/checks.ts +++ b/src/checks.ts @@ -10,14 +10,14 @@ const logWarningForSuperAdminEnvVariable = async (): Promise => { if (isVariablePresentInEnvFile) { logger.warn( "\x1b[1m\x1b[33m%s\x1b[0m", - "The LAST_RESORT_SUPERADMIN_EMAIL variable configured in your .env file poses a security risk. We strongly recommend that you remove it if not required. Please refer to the documentation in the INSTALLATION.md file.You have created super admin, please remove the LAST_RESORT_SUPERADMIN_EMAIL variable from .env file if you don't require it" + "The LAST_RESORT_SUPERADMIN_EMAIL variable configured in your .env file poses a security risk. We strongly recommend that you remove it if not required. Please refer to the documentation in the INSTALLATION.md file.You have created super admin, please remove the LAST_RESORT_SUPERADMIN_EMAIL variable from .env file if you don't require it", ); } } else { if (!isVariablePresentInEnvFile) { logger.warn( "\x1b[1m\x1b[33m%s\x1b[0m", - "To create your first Super Admin, the LAST_RESORT_SUPERADMIN_EMAIL parameter needs to be set in the .env file. Please refer to the documentation in the INSTALLATION.md file." + "To create your first Super Admin, the LAST_RESORT_SUPERADMIN_EMAIL parameter needs to be set in the .env file. Please refer to the documentation in the INSTALLATION.md file.", ); } } @@ -28,12 +28,12 @@ export const logIssues = async (): Promise => { const issues = getEnvIssues(); if (issues) { logger.error( - "Invalid environment variables found in your .env file, check the errors below!" + "Invalid environment variables found in your .env file, check the errors below!", ); console.error( generateErrorMessage(issues, { delimiter: { error: "\\n" }, - }) + }), ); } else { logger.info("The environment variables are valid!"); diff --git a/src/config/plugins/loadPlugins.ts b/src/config/plugins/loadPlugins.ts index 4393249868e..3d8d1582264 100644 --- a/src/config/plugins/loadPlugins.ts +++ b/src/config/plugins/loadPlugins.ts @@ -14,13 +14,13 @@ const loadPlugins = async (): Promise => { }); logger.info( "\x1b[1m\x1b[32m%s\x1b[0m", - `Uploaded Plugins in ${databaseTitle} ` + `Uploaded Plugins in ${databaseTitle} `, ); } else { //plugin data already present logger.info( "\x1b[1m\x1b[32m%s\x1b[0m", - `Plugin data already present at ${databaseTitle}` + `Plugin data already present at ${databaseTitle}`, ); } }; diff --git a/src/db.ts b/src/db.ts index 82c17e6d7e0..d5190fdf658 100644 --- a/src/db.ts +++ b/src/db.ts @@ -20,24 +20,24 @@ export const connect = async (): Promise => { logger.error("\n\n\n\x1b[1m\x1b[31m%s\x1b[0m", error); logger.error( "\n\n\x1b[1m\x1b[34m%s\x1b[0m", - `- Connection to MongoDB failed: There are several potential causes for this issue, including:` + `- Connection to MongoDB failed: There are several potential causes for this issue, including:`, ); logger.error( "\x1b[1m\x1b[33m%s\x1b[0m", - `- Unstable Network Connection` + `- Unstable Network Connection`, ); logger.error("\x1b[1m\x1b[33m%s\x1b[0m", `- Invalid Connection String`); logger.error( "\x1b[1m\x1b[33m%s\x1b[0m", - `- MongoDB Server may not be running` + `- MongoDB Server may not be running`, ); logger.error( "\x1b[1m\x1b[33m%s\x1b[0m", - `- Firewall may not be configured to allow incoming connections on MongoDB port.` + `- Firewall may not be configured to allow incoming connections on MongoDB port.`, ); logger.error( "\x1b[1m\x1b[31m%s\x1b[0m", - `- Please try again with the fixes !` + `- Please try again with the fixes !`, ); } else { logger.error("Error while connecting to mongo database", error); diff --git a/src/directives/directiveTransformer/authDirectiveTransformer.ts b/src/directives/directiveTransformer/authDirectiveTransformer.ts index a0bcb1cb2de..7773294b15e 100644 --- a/src/directives/directiveTransformer/authDirectiveTransformer.ts +++ b/src/directives/directiveTransformer/authDirectiveTransformer.ts @@ -6,13 +6,13 @@ import { errors, requestContext } from "../../libraries"; function authDirectiveTransformer(schema, directiveName): any { return mapSchema(schema, { [MapperKind.OBJECT_FIELD]: ( - fieldConfig: GraphQLFieldConfig + fieldConfig: GraphQLFieldConfig, ): any => { // Check whether this field has the specified directive const authDirective = getDirective( schema, fieldConfig, - directiveName + directiveName, )?.[0]; if (authDirective) { //@ts-ignore @@ -23,7 +23,7 @@ function authDirectiveTransformer(schema, directiveName): any { throw new errors.UnauthenticatedError( requestContext.translate("user.notAuthenticated"), "user.notAuthenticated --auth directive", - "userAuthentication" + "userAuthentication", ); return resolve(root, args, context, info); }; diff --git a/src/directives/directiveTransformer/roleDirectiveTransformer.ts b/src/directives/directiveTransformer/roleDirectiveTransformer.ts index ee424c1fef1..32e8d333c5d 100644 --- a/src/directives/directiveTransformer/roleDirectiveTransformer.ts +++ b/src/directives/directiveTransformer/roleDirectiveTransformer.ts @@ -11,13 +11,13 @@ import { MapperKind, getDirective, mapSchema } from "@graphql-tools/utils"; function roleDirectiveTransformer(schema, directiveName): any { return mapSchema(schema, { [MapperKind.OBJECT_FIELD]: ( - fieldConfig: GraphQLFieldConfig + fieldConfig: GraphQLFieldConfig, ): any => { // Check whether this field has the specified directive const roleDirective = getDirective( schema, fieldConfig, - directiveName + directiveName, )?.[0]; if (roleDirective) { @@ -31,7 +31,7 @@ function roleDirectiveTransformer(schema, directiveName): any { root, args, context, - info + info, ): Promise => { const currentUser = await User.findOne({ _id: context.userId, @@ -41,7 +41,7 @@ function roleDirectiveTransformer(schema, directiveName): any { throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.MESSAGE, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -49,7 +49,7 @@ function roleDirectiveTransformer(schema, directiveName): any { throw new errors.UnauthenticatedError( USER_NOT_AUTHORIZED_ERROR.MESSAGE, USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } diff --git a/src/helpers/eventInstances/once.ts b/src/helpers/eventInstances/once.ts index 4a844b48415..a206f446d45 100644 --- a/src/helpers/eventInstances/once.ts +++ b/src/helpers/eventInstances/once.ts @@ -11,7 +11,7 @@ export async function generateEvent( args: Partial, currentUser: InterfaceUser, organization: InterfaceOrganization, - session: mongoose.ClientSession + session: mongoose.ClientSession, ): Promise> { const createdEvent = await Event.create( [ @@ -22,7 +22,7 @@ export async function generateEvent( organization: organization._id, }, ], - { session } + { session }, ); return createdEvent; diff --git a/src/helpers/eventInstances/weekly.ts b/src/helpers/eventInstances/weekly.ts index 716fb7dcc30..db09d356f10 100644 --- a/src/helpers/eventInstances/weekly.ts +++ b/src/helpers/eventInstances/weekly.ts @@ -19,7 +19,7 @@ export async function generateEvents( args: Partial, currentUser: InterfaceUser, organization: InterfaceOrganization, - session: mongoose.ClientSession + session: mongoose.ClientSession, ): Promise { const recurringEvents: InterfaceRecurringEvent[] = []; const { data } = args; @@ -29,7 +29,7 @@ export async function generateEvents( const allDays = eachDayOfInterval({ start: startDate, end: endDate }); const occurrences = allDays.filter( - (date) => date.getDay() === startDate.getDay() + (date) => date.getDay() === startDate.getDay(), ); occurrences.map((date) => { diff --git a/src/index.ts b/src/index.ts index 68a369e19b3..593ad34d0b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,14 +46,14 @@ const httpServer = cert: fs.readFileSync(path.join(__dirname, "../cert.pem")), }, // :{} - app + app, ) : http.createServer(app); const server = new ApolloServer({ schema, formatError: ( - error: any + error: any, ): { message: string; status: number; data: string[] } => { if (!error.originalError) { return error; @@ -99,7 +99,7 @@ const wsServer = new WebSocketServer({ const serverCleanup = useServer( // eslint-disable-next-line @typescript-eslint/no-unused-vars { schema, context: (_ctx, _msg, _args) => ({ pubsub }) }, - wsServer + wsServer, ); async function startServer(): Promise { @@ -117,12 +117,12 @@ async function startServer(): Promise { pubsub, apiRootUrl: `${req.protocol}://${req.get("host")}/`, }), - }) + }), ); // Modified server startup await new Promise((resolve) => - httpServer.listen({ port: 4000 }, resolve) + httpServer.listen({ port: 4000 }, resolve), ); // Log all the configuration related issues @@ -131,7 +131,7 @@ async function startServer(): Promise { logger.info( `🚀 Server ready at ${ process.env.NODE_ENV === "production" ? "https" : "http" - }://localhost:4000/graphql` + }://localhost:4000/graphql`, ); logger.info(`🚀 Subscription endpoint ready at ws://localhost:4000/graphql`); } diff --git a/src/libraries/dbLogger.ts b/src/libraries/dbLogger.ts index bf2b2249096..65a76bf943a 100644 --- a/src/libraries/dbLogger.ts +++ b/src/libraries/dbLogger.ts @@ -39,7 +39,7 @@ export interface InterfaceLoggableQuery extends Query { export function createLoggingMiddleware( schema: Schema, - modelName: string + modelName: string, ): void { if (!dbLogger) { return; @@ -47,7 +47,7 @@ export function createLoggingMiddleware( const logAction = ( type: TransactionLogTypes, - thisContext?: InterfaceLoggableQuery + thisContext?: InterfaceLoggableQuery, ): TransactionLogInfo => { return { timestamp: new Date().toISOString(), diff --git a/src/libraries/errors/ImageSizeLimitExceeded.ts b/src/libraries/errors/ImageSizeLimitExceeded.ts index 7daf08b902e..efbb92db6df 100644 --- a/src/libraries/errors/ImageSizeLimitExceeded.ts +++ b/src/libraries/errors/ImageSizeLimitExceeded.ts @@ -7,7 +7,7 @@ export class ImageSizeLimitExceeded extends ApplicationError { message = "Image Size Limit Exceeded", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/conflictError.ts b/src/libraries/errors/conflictError.ts index 0cd75755be5..8de09db2757 100644 --- a/src/libraries/errors/conflictError.ts +++ b/src/libraries/errors/conflictError.ts @@ -7,7 +7,7 @@ export class ConflictError extends ApplicationError { message = "Conflicting entry found", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/inputValidationError.ts b/src/libraries/errors/inputValidationError.ts index 2f1afd1b479..7055169c122 100644 --- a/src/libraries/errors/inputValidationError.ts +++ b/src/libraries/errors/inputValidationError.ts @@ -7,7 +7,7 @@ export class InputValidationError extends ApplicationError { message = "InputValidationError", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/internalServerError.ts b/src/libraries/errors/internalServerError.ts index fd32a7bce44..283d9ea4078 100644 --- a/src/libraries/errors/internalServerError.ts +++ b/src/libraries/errors/internalServerError.ts @@ -7,7 +7,7 @@ export class InternalServerError extends ApplicationError { message = "Internal Server Error!", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/invalidFileTypeError.ts b/src/libraries/errors/invalidFileTypeError.ts index 4de379aafdd..07bc726637c 100644 --- a/src/libraries/errors/invalidFileTypeError.ts +++ b/src/libraries/errors/invalidFileTypeError.ts @@ -7,7 +7,7 @@ export class InvalidFileTypeError extends ApplicationError { message = "Invalid File Type", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/notFoundError.ts b/src/libraries/errors/notFoundError.ts index 89df18e5163..1b5d04f9b2a 100644 --- a/src/libraries/errors/notFoundError.ts +++ b/src/libraries/errors/notFoundError.ts @@ -7,7 +7,7 @@ export class NotFoundError extends ApplicationError { message = "Not Found", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/unauthenticatedError.ts b/src/libraries/errors/unauthenticatedError.ts index 9e3f1ec8cb5..571c661eb0c 100644 --- a/src/libraries/errors/unauthenticatedError.ts +++ b/src/libraries/errors/unauthenticatedError.ts @@ -7,7 +7,7 @@ export class UnauthenticatedError extends ApplicationError { message = "UnauthenticatedError", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/errors/unauthorizedError.ts b/src/libraries/errors/unauthorizedError.ts index 7a6a972eb21..8482627c5e8 100644 --- a/src/libraries/errors/unauthorizedError.ts +++ b/src/libraries/errors/unauthorizedError.ts @@ -7,7 +7,7 @@ export class UnauthorizedError extends ApplicationError { message = "UnauthorizedError", code: string | null = null, param: string | null = null, - metadata: Record = {} + metadata: Record = {}, ) { const errorJson = [ { diff --git a/src/libraries/logger.ts b/src/libraries/logger.ts index 0bdc28f2475..194d6275114 100644 --- a/src/libraries/logger.ts +++ b/src/libraries/logger.ts @@ -20,10 +20,10 @@ const formats = { .length === 0 ? "" : JSON.stringify( - _.omit(info, ["level", "message", "stack", "timestamp"]) + _.omit(info, ["level", "message", "stack", "timestamp"]), ) - } ${info.stack || ""}` - ) + } ${info.stack || ""}`, + ), ), non_colorized: combine( splat(), @@ -38,10 +38,10 @@ const formats = { .length === 0 ? "" : JSON.stringify( - _.omit(info, ["level", "message", "stack", "timestamp"]) + _.omit(info, ["level", "message", "stack", "timestamp"]), ) - } ${info.stack || ""}` - ) + } ${info.stack || ""}`, + ), ), }; diff --git a/src/libraries/requestContext.ts b/src/libraries/requestContext.ts index 8b29e504e5a..e404cc2ebdf 100644 --- a/src/libraries/requestContext.ts +++ b/src/libraries/requestContext.ts @@ -6,7 +6,7 @@ import i18n from "i18n"; import type { NextFunction, Request, Response } from "express"; export const requestContextNamespace = cls.createNamespace( - "talawa-request-context" + "talawa-request-context", ); clsBluebird(requestContextNamespace); diff --git a/src/libraries/requestTracing.ts b/src/libraries/requestTracing.ts index 20b01b0ad49..33aa61e69b1 100644 --- a/src/libraries/requestTracing.ts +++ b/src/libraries/requestTracing.ts @@ -49,7 +49,7 @@ export const middleware = () => { export const trace = async ( tracingId: string, - method: () => T + method: () => T, ): Promise => { await requestTracingNamespace.runAndReturn(() => { setTracingId(tracingId || nanoid()); diff --git a/src/libraries/validators/validatePaginationArgs.ts b/src/libraries/validators/validatePaginationArgs.ts index 69751fce8e5..9b431fd6bd2 100644 --- a/src/libraries/validators/validatePaginationArgs.ts +++ b/src/libraries/validators/validatePaginationArgs.ts @@ -5,7 +5,7 @@ import type { } from "../../types/generatedGraphQLTypes"; export const validatePaginationArgs = ( - args: CursorPaginationInput + args: CursorPaginationInput, ): ConnectionError[] => { const connectionErrors: ConnectionError[] = []; diff --git a/src/libraries/validators/validateString.ts b/src/libraries/validators/validateString.ts index 30708145bff..eff049c5c13 100644 --- a/src/libraries/validators/validateString.ts +++ b/src/libraries/validators/validateString.ts @@ -1,6 +1,6 @@ export function isValidString( str: string, - maxLength: number + maxLength: number, ): { isLessThanMaxLength: boolean } { const isLessThanMaxLength: boolean = str.length < maxLength; return { diff --git a/src/middleware/isAuth.ts b/src/middleware/isAuth.ts index 410d90a3fb3..f1cb943f194 100644 --- a/src/middleware/isAuth.ts +++ b/src/middleware/isAuth.ts @@ -56,7 +56,7 @@ export const isAuth = (request: Request): InterfaceAuthData => { return err; } return decoded; - } + }, ); // If there is an error decoded token would contain it if (decodedToken.name === "TokenExpiredError") { diff --git a/src/models/ActionItem.ts b/src/models/ActionItem.ts index 1cbbb2ef499..31f0324e2c2 100644 --- a/src/models/ActionItem.ts +++ b/src/models/ActionItem.ts @@ -96,7 +96,7 @@ const actionItemSchema = new Schema( required: true, }, }, - { timestamps: true } + { timestamps: true }, ); const actionItemModel = (): Model => diff --git a/src/models/ActionItemCategory.ts b/src/models/ActionItemCategory.ts index 4110dfa88cf..3660085c9c1 100644 --- a/src/models/ActionItemCategory.ts +++ b/src/models/ActionItemCategory.ts @@ -49,18 +49,18 @@ const actionItemCategorySchema = new Schema( required: true, }, }, - { timestamps: true } + { timestamps: true }, ); actionItemCategorySchema.index( { organizationId: 1, name: 1 }, - { unique: true } + { unique: true }, ); const actionItemCategoryModel = (): Model => model( "ActionItemCategory", - actionItemCategorySchema + actionItemCategorySchema, ); // This syntax is needed to prevent Mongoose OverwriteModelError while running tests. diff --git a/src/models/Advertisement.ts b/src/models/Advertisement.ts index 2aacecf2e8a..b59d7d134c8 100644 --- a/src/models/Advertisement.ts +++ b/src/models/Advertisement.ts @@ -96,7 +96,7 @@ const advertisementSchema = new Schema( }, { timestamps: true, - } + }, ); const advertisementModel = (): Model => diff --git a/src/models/CheckIn.ts b/src/models/CheckIn.ts index 05e2276b462..45c7c272954 100644 --- a/src/models/CheckIn.ts +++ b/src/models/CheckIn.ts @@ -48,7 +48,7 @@ const checkInSchema = new Schema( }, { timestamps: true, - } + }, ); // We will also create an index here for faster database querying diff --git a/src/models/Comment.ts b/src/models/Comment.ts index dc78a65e7c0..be1ddef0e51 100644 --- a/src/models/Comment.ts +++ b/src/models/Comment.ts @@ -62,7 +62,7 @@ const commentSchema = new Schema( }, { timestamps: true, - } + }, ); const commentModel = (): Model => diff --git a/src/models/DirectChat.ts b/src/models/DirectChat.ts index 94b87c86bbb..2b4c6639207 100644 --- a/src/models/DirectChat.ts +++ b/src/models/DirectChat.ts @@ -60,7 +60,7 @@ const directChatSchema = new Schema( }, { timestamps: true, - } + }, ); const directChatModel = (): Model => diff --git a/src/models/DirectChatMessage.ts b/src/models/DirectChatMessage.ts index 3453ceee0ef..7f713e8fdc8 100644 --- a/src/models/DirectChatMessage.ts +++ b/src/models/DirectChatMessage.ts @@ -55,13 +55,13 @@ const directChatMessageSchema = new Schema( }, { timestamps: true, - } + }, ); const directChatMessageModel = (): Model => model( "DirectChatMessage", - directChatMessageSchema + directChatMessageSchema, ); // This syntax is needed to prevent Mongoose OverwriteModelError while running tests. diff --git a/src/models/Donation.ts b/src/models/Donation.ts index e8e2e5225f3..bc72bb06e5b 100644 --- a/src/models/Donation.ts +++ b/src/models/Donation.ts @@ -53,7 +53,7 @@ const donationSchema = new Schema( }, { timestamps: true, - } + }, ); const donationModel = (): Model => diff --git a/src/models/Event.ts b/src/models/Event.ts index 05b72ac0f58..0e46b0c4078 100644 --- a/src/models/Event.ts +++ b/src/models/Event.ts @@ -158,7 +158,7 @@ const eventSchema = new Schema( }, { timestamps: true, - } + }, ); const eventModel = (): Model => diff --git a/src/models/Feedback.ts b/src/models/Feedback.ts index 9ee07e88c87..bfa1b8f77aa 100644 --- a/src/models/Feedback.ts +++ b/src/models/Feedback.ts @@ -31,7 +31,7 @@ const feedbackSchema = new Schema( }, { timestamps: true, - } + }, ); // We will also create an index here for faster database querying diff --git a/src/models/File.ts b/src/models/File.ts index c8e286b61f3..7116dd2742d 100644 --- a/src/models/File.ts +++ b/src/models/File.ts @@ -55,7 +55,7 @@ const fileSchema = new Schema( }, { timestamps: true, - } + }, ); const fileModel = (): Model => diff --git a/src/models/Group.ts b/src/models/Group.ts index ac641c4a945..ba45ff3b05b 100644 --- a/src/models/Group.ts +++ b/src/models/Group.ts @@ -54,7 +54,7 @@ const groupSchema = new Schema( }, { timestamps: true, - } + }, ); const groupModel = (): Model => diff --git a/src/models/GroupChat.ts b/src/models/GroupChat.ts index 7d2f5fa68b6..70ba68e3643 100644 --- a/src/models/GroupChat.ts +++ b/src/models/GroupChat.ts @@ -66,7 +66,7 @@ const groupChatSchema = new Schema( }, { timestamps: true, - } + }, ); const groupChatModel = (): Model => diff --git a/src/models/GroupChatMessage.ts b/src/models/GroupChatMessage.ts index 378cb78442a..34ac757f81f 100644 --- a/src/models/GroupChatMessage.ts +++ b/src/models/GroupChatMessage.ts @@ -48,7 +48,7 @@ const groupChatMessageSchema = new Schema( }, { timestamps: true, - } + }, ); const groupChatMessageModel = (): Model => diff --git a/src/models/MembershipRequest.ts b/src/models/MembershipRequest.ts index 6118a176cdd..6e1479ff92e 100644 --- a/src/models/MembershipRequest.ts +++ b/src/models/MembershipRequest.ts @@ -39,7 +39,7 @@ const membershipRequestSchema = new Schema({ const membershipRequestModel = (): Model => model( "MembershipRequest", - membershipRequestSchema + membershipRequestSchema, ); // This syntax is needed to prevent Mongoose OverwriteModelError while running tests. diff --git a/src/models/Message.ts b/src/models/Message.ts index 5358903b014..c15f8314bf8 100644 --- a/src/models/Message.ts +++ b/src/models/Message.ts @@ -60,7 +60,7 @@ const messageSchema = new Schema( }, { timestamps: true, - } + }, ); const messageModel = (): Model => diff --git a/src/models/MessageChat.ts b/src/models/MessageChat.ts index 48c6af48c22..74b3e3f9c2a 100644 --- a/src/models/MessageChat.ts +++ b/src/models/MessageChat.ts @@ -46,7 +46,7 @@ const messageChatSchema = new Schema( }, { timestamps: true, - } + }, ); const messageChatModel = (): Model => diff --git a/src/models/Organization.ts b/src/models/Organization.ts index 2ee482bea6a..68fae7aba96 100644 --- a/src/models/Organization.ts +++ b/src/models/Organization.ts @@ -174,7 +174,7 @@ const organizationSchema = new Schema( }, { timestamps: true, - } + }, ); const organizationModel = (): Model => diff --git a/src/models/OrganizationCustomField.ts b/src/models/OrganizationCustomField.ts index 5559a55e6ed..070cb254a49 100644 --- a/src/models/OrganizationCustomField.ts +++ b/src/models/OrganizationCustomField.ts @@ -30,7 +30,7 @@ const OrganizationCustomField: Model = mongoose.models.CustomField || mongoose.model( "CustomField", - organizationCustomFieldSchema + organizationCustomFieldSchema, ); export { OrganizationCustomField }; diff --git a/src/models/OrganizationTagUser.ts b/src/models/OrganizationTagUser.ts index c185b415321..107fc7c5ab1 100644 --- a/src/models/OrganizationTagUser.ts +++ b/src/models/OrganizationTagUser.ts @@ -32,13 +32,13 @@ const organizationTagUserSchema = new Schema({ organizationTagUserSchema.index( { organizationId: 1, parentOrganizationTagUserId: 1, name: 1 }, - { unique: true } + { unique: true }, ); const organizationTagUserModel = (): Model => model( "OrganizationTagUser", - organizationTagUserSchema + organizationTagUserSchema, ); // This syntax is needed to prevent Mongoose OverwriteModelError while running tests. diff --git a/src/models/Post.ts b/src/models/Post.ts index efcf27f4158..93fe73f60fe 100644 --- a/src/models/Post.ts +++ b/src/models/Post.ts @@ -92,7 +92,7 @@ const postSchema = new Schema( }, { timestamps: true, - } + }, ); postSchema.plugin(mongoosePaginate); diff --git a/src/resolvers/ActionItemCategory/creator.ts b/src/resolvers/ActionItemCategory/creator.ts index b9d355ed0a8..8ccffc6a6a1 100644 --- a/src/resolvers/ActionItemCategory/creator.ts +++ b/src/resolvers/ActionItemCategory/creator.ts @@ -2,7 +2,7 @@ import type { ActionItemCategoryResolvers } from "../../types/generatedGraphQLTy import { User } from "../../models"; export const creator: ActionItemCategoryResolvers["creator"] = async ( - parent + parent, ) => { return User.findOne({ _id: parent.creatorId, diff --git a/src/resolvers/ActionItemCategory/organization.ts b/src/resolvers/ActionItemCategory/organization.ts index 98fcb42897d..3981d6cb658 100644 --- a/src/resolvers/ActionItemCategory/organization.ts +++ b/src/resolvers/ActionItemCategory/organization.ts @@ -2,7 +2,7 @@ import type { ActionItemCategoryResolvers } from "../../types/generatedGraphQLTy import { Organization } from "../../models"; export const organization: ActionItemCategoryResolvers["organization"] = async ( - parent + parent, ) => { return Organization.findOne({ _id: parent.organizationId, diff --git a/src/resolvers/DirectChat/organization.ts b/src/resolvers/DirectChat/organization.ts index b03f7ded3d9..ac1ec7ee8fb 100644 --- a/src/resolvers/DirectChat/organization.ts +++ b/src/resolvers/DirectChat/organization.ts @@ -8,7 +8,7 @@ import type { DirectChatResolvers } from "../../types/generatedGraphQLTypes"; * @returns An `object` that contains Organization data. */ export const organization: DirectChatResolvers["organization"] = async ( - parent + parent, ) => { const organizationFoundInCache = await findOrganizationsInCache([ parent.organization, diff --git a/src/resolvers/DirectChatMessage/receiver.ts b/src/resolvers/DirectChatMessage/receiver.ts index c00ee780299..ac565f8497b 100644 --- a/src/resolvers/DirectChatMessage/receiver.ts +++ b/src/resolvers/DirectChatMessage/receiver.ts @@ -6,7 +6,7 @@ import { User } from "../../models"; * @returns An `object` that contains User's data. */ export const receiver: DirectChatMessageResolvers["receiver"] = async ( - parent + parent, ) => { return await User.findOne({ _id: parent.receiver, diff --git a/src/resolvers/Event/attendees.ts b/src/resolvers/Event/attendees.ts index e057ae09b05..547bf38b610 100644 --- a/src/resolvers/Event/attendees.ts +++ b/src/resolvers/Event/attendees.ts @@ -9,6 +9,6 @@ export const attendees: EventResolvers["attendees"] = async (parent) => { .lean(); return eventAttendeeObjects.map( - (eventAttendeeObject) => eventAttendeeObject.userId + (eventAttendeeObject) => eventAttendeeObject.userId, ); }; diff --git a/src/resolvers/Event/averageFeedbackScore.ts b/src/resolvers/Event/averageFeedbackScore.ts index 7b6818ec6b6..087eca38e9b 100644 --- a/src/resolvers/Event/averageFeedbackScore.ts +++ b/src/resolvers/Event/averageFeedbackScore.ts @@ -14,7 +14,7 @@ export const averageFeedbackScore: EventResolvers["averageFeedbackScore"] = // Return the average feedback score const sum = feedbacks.reduce( (accumulator, feedback) => accumulator + feedback.rating, - 0 + 0, ); return sum / feedbacks.length; }; diff --git a/src/resolvers/GroupChat/organization.ts b/src/resolvers/GroupChat/organization.ts index 35c33c705c1..ed0480e4d33 100644 --- a/src/resolvers/GroupChat/organization.ts +++ b/src/resolvers/GroupChat/organization.ts @@ -8,7 +8,7 @@ import { findOrganizationsInCache } from "../../services/OrganizationCache/findO * @returns An `object` that contains the organization data. */ export const organization: GroupChatResolvers["organization"] = async ( - parent + parent, ) => { const organizationFoundInCache = await findOrganizationsInCache([ parent.organization, diff --git a/src/resolvers/MembershipRequest/organization.ts b/src/resolvers/MembershipRequest/organization.ts index 1b0c58ac6ae..a80b14540c7 100644 --- a/src/resolvers/MembershipRequest/organization.ts +++ b/src/resolvers/MembershipRequest/organization.ts @@ -6,7 +6,7 @@ import { Organization } from "../../models"; * @returns An object that contains the Organization data. */ export const organization: MembershipRequestResolvers["organization"] = async ( - parent + parent, ) => { return Organization.findOne({ _id: parent.organization, diff --git a/src/resolvers/Mutation/acceptAdmin.ts b/src/resolvers/Mutation/acceptAdmin.ts index 109a1476f3f..ba787b70899 100644 --- a/src/resolvers/Mutation/acceptAdmin.ts +++ b/src/resolvers/Mutation/acceptAdmin.ts @@ -15,7 +15,7 @@ import { superAdminCheck } from "../../utilities/superAdminCheck"; export const acceptAdmin: MutationResolvers["acceptAdmin"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -25,7 +25,7 @@ export const acceptAdmin: MutationResolvers["acceptAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -39,7 +39,7 @@ export const acceptAdmin: MutationResolvers["acceptAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -51,7 +51,7 @@ export const acceptAdmin: MutationResolvers["acceptAdmin"] = async ( $set: { adminApproved: true, }, - } + }, ); return true; diff --git a/src/resolvers/Mutation/acceptMembershipRequest.ts b/src/resolvers/Mutation/acceptMembershipRequest.ts index 18d650cd141..44394d143f5 100644 --- a/src/resolvers/Mutation/acceptMembershipRequest.ts +++ b/src/resolvers/Mutation/acceptMembershipRequest.ts @@ -35,7 +35,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest throw new errors.NotFoundError( requestContext.translate(MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE), MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.CODE, - MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM + MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM, ); } @@ -46,7 +46,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -57,7 +57,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -65,7 +65,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest await adminCheck(context.userId, organization); const userIsOrganizationMember = organization.members.some( - (member: Types.ObjectId) => member.equals(user?._id) + (member: Types.ObjectId) => member.equals(user?._id), ); // Checks whether user is already a member of organization. @@ -73,7 +73,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest throw new errors.ConflictError( requestContext.translate(USER_ALREADY_MEMBER_ERROR.MESSAGE), USER_ALREADY_MEMBER_ERROR.CODE, - USER_ALREADY_MEMBER_ERROR.PARAM + USER_ALREADY_MEMBER_ERROR.PARAM, ); } @@ -97,7 +97,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -116,7 +116,7 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest $pull: { membershipRequests: membershipRequest._id, }, - } + }, ); return membershipRequest; diff --git a/src/resolvers/Mutation/addEventAttendee.ts b/src/resolvers/Mutation/addEventAttendee.ts index 955eb3da69b..5ad788b6692 100644 --- a/src/resolvers/Mutation/addEventAttendee.ts +++ b/src/resolvers/Mutation/addEventAttendee.ts @@ -15,7 +15,7 @@ import { Types } from "mongoose"; export const addEventAttendee: MutationResolvers["addEventAttendee"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -25,7 +25,7 @@ export const addEventAttendee: MutationResolvers["addEventAttendee"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -49,20 +49,20 @@ export const addEventAttendee: MutationResolvers["addEventAttendee"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } const isUserEventAdmin = event.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || Types.ObjectId(admin).equals(context.userId), ); if (!isUserEventAdmin && currentUser.userType !== "SUPERADMIN") { throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -74,7 +74,7 @@ export const addEventAttendee: MutationResolvers["addEventAttendee"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -86,7 +86,7 @@ export const addEventAttendee: MutationResolvers["addEventAttendee"] = async ( throw new errors.ConflictError( requestContext.translate(USER_ALREADY_REGISTERED_FOR_EVENT.MESSAGE), USER_ALREADY_REGISTERED_FOR_EVENT.CODE, - USER_ALREADY_REGISTERED_FOR_EVENT.PARAM + USER_ALREADY_REGISTERED_FOR_EVENT.PARAM, ); } diff --git a/src/resolvers/Mutation/addFeedback.ts b/src/resolvers/Mutation/addFeedback.ts index 1b34340f228..8923e63dfb3 100644 --- a/src/resolvers/Mutation/addFeedback.ts +++ b/src/resolvers/Mutation/addFeedback.ts @@ -11,7 +11,7 @@ import { Event, EventAttendee, CheckIn, Feedback } from "../../models"; export const addFeedback: MutationResolvers["addFeedback"] = async ( _parent, args, - context + context, ) => { const currentEventExists = await Event.exists({ _id: args.data.eventId, @@ -21,7 +21,7 @@ export const addFeedback: MutationResolvers["addFeedback"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } @@ -36,7 +36,7 @@ export const addFeedback: MutationResolvers["addFeedback"] = async ( throw new errors.ConflictError( requestContext.translate(USER_NOT_REGISTERED_FOR_EVENT.MESSAGE), USER_NOT_REGISTERED_FOR_EVENT.CODE, - USER_NOT_REGISTERED_FOR_EVENT.PARAM + USER_NOT_REGISTERED_FOR_EVENT.PARAM, ); } @@ -44,7 +44,7 @@ export const addFeedback: MutationResolvers["addFeedback"] = async ( throw new errors.ConflictError( requestContext.translate(USER_NOT_CHECKED_IN.MESSAGE), USER_NOT_CHECKED_IN.CODE, - USER_NOT_CHECKED_IN.PARAM + USER_NOT_CHECKED_IN.PARAM, ); } @@ -52,7 +52,7 @@ export const addFeedback: MutationResolvers["addFeedback"] = async ( throw new errors.ConflictError( requestContext.translate(FEEDBACK_ALREADY_SUBMITTED.MESSAGE), FEEDBACK_ALREADY_SUBMITTED.CODE, - FEEDBACK_ALREADY_SUBMITTED.PARAM + FEEDBACK_ALREADY_SUBMITTED.PARAM, ); } diff --git a/src/resolvers/Mutation/addLanguageTranslation.ts b/src/resolvers/Mutation/addLanguageTranslation.ts index 228194c7b1f..c5c364124b5 100644 --- a/src/resolvers/Mutation/addLanguageTranslation.ts +++ b/src/resolvers/Mutation/addLanguageTranslation.ts @@ -25,7 +25,7 @@ export const addLanguageTranslation: MutationResolvers["addLanguageTranslation"] throw new errors.ConflictError( requestContext.translate(TRANSLATION_ALREADY_PRESENT_ERROR.MESSAGE), TRANSLATION_ALREADY_PRESENT_ERROR.CODE, - TRANSLATION_ALREADY_PRESENT_ERROR.PARAM + TRANSLATION_ALREADY_PRESENT_ERROR.PARAM, ); } }); @@ -45,7 +45,7 @@ export const addLanguageTranslation: MutationResolvers["addLanguageTranslation"] }, { new: true, - } + }, ).lean(); } diff --git a/src/resolvers/Mutation/addOrganizationCustomField.ts b/src/resolvers/Mutation/addOrganizationCustomField.ts index af5eb832aaa..3f7ee20558c 100644 --- a/src/resolvers/Mutation/addOrganizationCustomField.ts +++ b/src/resolvers/Mutation/addOrganizationCustomField.ts @@ -32,7 +32,7 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -44,12 +44,12 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(organization._id) + (organization) => organization.equals(organization._id), ); if ( @@ -58,7 +58,7 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -66,7 +66,7 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto throw new errors.InputValidationError( requestContext.translate(CUSTOM_FIELD_NAME_MISSING.MESSAGE), CUSTOM_FIELD_NAME_MISSING.CODE, - CUSTOM_FIELD_NAME_MISSING.PARAM + CUSTOM_FIELD_NAME_MISSING.PARAM, ); } @@ -74,7 +74,7 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto throw new errors.InputValidationError( requestContext.translate(CUSTOM_FIELD_TYPE_MISSING.MESSAGE), CUSTOM_FIELD_TYPE_MISSING.CODE, - CUSTOM_FIELD_TYPE_MISSING.PARAM + CUSTOM_FIELD_TYPE_MISSING.PARAM, ); } @@ -90,7 +90,7 @@ export const addOrganizationCustomField: MutationResolvers["addOrganizationCusto { _id: organization._id }, { $push: { collectionFields: newCollectionField._id }, - } + }, ).lean(); return newCollectionField; diff --git a/src/resolvers/Mutation/addOrganizationImage.ts b/src/resolvers/Mutation/addOrganizationImage.ts index b466a824313..d6b95a1912e 100644 --- a/src/resolvers/Mutation/addOrganizationImage.ts +++ b/src/resolvers/Mutation/addOrganizationImage.ts @@ -39,7 +39,7 @@ export const addOrganizationImage: MutationResolvers["addOrganizationImage"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -49,7 +49,7 @@ export const addOrganizationImage: MutationResolvers["addOrganizationImage"] = // Upload Image const uploadImageFileName = await uploadEncodedImage( args.file, - organization.image + organization.image, ); // Updates the organization with new image and returns the updated organization. const updatedOrganization = await Organization.findOneAndUpdate( @@ -63,7 +63,7 @@ export const addOrganizationImage: MutationResolvers["addOrganizationImage"] = }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/src/resolvers/Mutation/addUserCustomData.ts b/src/resolvers/Mutation/addUserCustomData.ts index f752f8e1bc4..47ff41d982b 100644 --- a/src/resolvers/Mutation/addUserCustomData.ts +++ b/src/resolvers/Mutation/addUserCustomData.ts @@ -20,7 +20,7 @@ import { export const addUserCustomData: MutationResolvers["addUserCustomData"] = async ( _parent, args, - context + context, ) => { const { organizationId, dataName, dataValue } = args; @@ -29,7 +29,7 @@ export const addUserCustomData: MutationResolvers["addUserCustomData"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -38,7 +38,7 @@ export const addUserCustomData: MutationResolvers["addUserCustomData"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/addUserImage.ts b/src/resolvers/Mutation/addUserImage.ts index bade6c21e52..3bd0a66b8e0 100644 --- a/src/resolvers/Mutation/addUserImage.ts +++ b/src/resolvers/Mutation/addUserImage.ts @@ -15,7 +15,7 @@ import { uploadEncodedImage } from "../../utilities/encodedImageStorage/uploadEn export const addUserImage: MutationResolvers["addUserImage"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -26,13 +26,13 @@ export const addUserImage: MutationResolvers["addUserImage"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const imageToUploadFilePath = await uploadEncodedImage( args.file, - currentUser.image + currentUser.image, ); // Updates the user with new image and returns the updated user. @@ -47,6 +47,6 @@ export const addUserImage: MutationResolvers["addUserImage"] = async ( }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/addUserToGroupChat.ts b/src/resolvers/Mutation/addUserToGroupChat.ts index ad8b49981fa..b72966ac542 100644 --- a/src/resolvers/Mutation/addUserToGroupChat.ts +++ b/src/resolvers/Mutation/addUserToGroupChat.ts @@ -35,7 +35,7 @@ export const addUserToGroupChat: MutationResolvers["addUserToGroupChat"] = throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -59,7 +59,7 @@ export const addUserToGroupChat: MutationResolvers["addUserToGroupChat"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -75,12 +75,12 @@ export const addUserToGroupChat: MutationResolvers["addUserToGroupChat"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const isUserGroupChatMember = groupChat.users.some((user) => - user.equals(args.userId) + user.equals(args.userId), ); // Checks whether user with _id === args.userId is already a member of groupChat. @@ -88,7 +88,7 @@ export const addUserToGroupChat: MutationResolvers["addUserToGroupChat"] = throw new errors.ConflictError( requestContext.translate(USER_ALREADY_MEMBER_ERROR.MESSAGE), USER_ALREADY_MEMBER_ERROR.CODE, - USER_ALREADY_MEMBER_ERROR.PARAM + USER_ALREADY_MEMBER_ERROR.PARAM, ); } @@ -104,6 +104,6 @@ export const addUserToGroupChat: MutationResolvers["addUserToGroupChat"] = }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/adminRemoveEvent.ts b/src/resolvers/Mutation/adminRemoveEvent.ts index a2b17f472f3..34490414037 100644 --- a/src/resolvers/Mutation/adminRemoveEvent.ts +++ b/src/resolvers/Mutation/adminRemoveEvent.ts @@ -27,7 +27,7 @@ import { deleteEventFromCache } from "../../services/EventCache/deleteEventFromC export const adminRemoveEvent: MutationResolvers["adminRemoveEvent"] = async ( _parent, args, - context + context, ) => { let event; @@ -50,7 +50,7 @@ export const adminRemoveEvent: MutationResolvers["adminRemoveEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } @@ -74,7 +74,7 @@ export const adminRemoveEvent: MutationResolvers["adminRemoveEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -87,7 +87,7 @@ export const adminRemoveEvent: MutationResolvers["adminRemoveEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -108,7 +108,7 @@ export const adminRemoveEvent: MutationResolvers["adminRemoveEvent"] = async ( createdEvents: event._id, registeredEvents: event._id, }, - } + }, ); // Deletes the event. diff --git a/src/resolvers/Mutation/adminRemoveGroup.ts b/src/resolvers/Mutation/adminRemoveGroup.ts index 0769b10f7f5..8d1c39723f1 100644 --- a/src/resolvers/Mutation/adminRemoveGroup.ts +++ b/src/resolvers/Mutation/adminRemoveGroup.ts @@ -25,7 +25,7 @@ import { cacheOrganizations } from "../../services/OrganizationCache/cacheOrgani export const adminRemoveGroup: MutationResolvers["adminRemoveGroup"] = async ( _parent, args, - context + context, ) => { const groupChat = await GroupChat.findOne({ _id: args.groupId, @@ -36,7 +36,7 @@ export const adminRemoveGroup: MutationResolvers["adminRemoveGroup"] = async ( throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -61,7 +61,7 @@ export const adminRemoveGroup: MutationResolvers["adminRemoveGroup"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -74,7 +74,7 @@ export const adminRemoveGroup: MutationResolvers["adminRemoveGroup"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/assignUserTag.ts b/src/resolvers/Mutation/assignUserTag.ts index 1cd81c67c5d..3e19aaf4870 100644 --- a/src/resolvers/Mutation/assignUserTag.ts +++ b/src/resolvers/Mutation/assignUserTag.ts @@ -12,7 +12,7 @@ import { export const assignUserTag: MutationResolvers["assignUserTag"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -23,7 +23,7 @@ export const assignUserTag: MutationResolvers["assignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -36,13 +36,13 @@ export const assignUserTag: MutationResolvers["assignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(TAG_NOT_FOUND.MESSAGE), TAG_NOT_FOUND.CODE, - TAG_NOT_FOUND.PARAM + TAG_NOT_FOUND.PARAM, ); } // Boolean to determine whether user is an admin of organization of the tag. const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(tag.organizationId) + (organization) => organization.equals(tag.organizationId), ); // Checks whether currentUser can assign the tag or not. @@ -53,7 +53,7 @@ export const assignUserTag: MutationResolvers["assignUserTag"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -66,23 +66,23 @@ export const assignUserTag: MutationResolvers["assignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // Check that the user to which the tag is to be assigned is a member of the tag's organization const requestUserBelongsToTagOrganization = requestUser.joinedOrganizations.some((organization) => - organization.equals(tag.organizationId) + organization.equals(tag.organizationId), ); if (!requestUserBelongsToTagOrganization) { throw new errors.UnauthorizedError( requestContext.translate( - USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE + USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE, ), USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.CODE, - USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.PARAM + USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.PARAM, ); } @@ -95,7 +95,7 @@ export const assignUserTag: MutationResolvers["assignUserTag"] = async ( throw new errors.ConflictError( requestContext.translate(USER_ALREADY_HAS_TAG.MESSAGE), USER_ALREADY_HAS_TAG.CODE, - USER_ALREADY_HAS_TAG.PARAM + USER_ALREADY_HAS_TAG.PARAM, ); } diff --git a/src/resolvers/Mutation/blockPluginCreationBySuperadmin.ts b/src/resolvers/Mutation/blockPluginCreationBySuperadmin.ts index b196752abb1..17f2db8fd54 100644 --- a/src/resolvers/Mutation/blockPluginCreationBySuperadmin.ts +++ b/src/resolvers/Mutation/blockPluginCreationBySuperadmin.ts @@ -24,7 +24,7 @@ export const blockPluginCreationBySuperadmin: MutationResolvers["blockPluginCrea throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -46,6 +46,6 @@ export const blockPluginCreationBySuperadmin: MutationResolvers["blockPluginCrea }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/blockUser.ts b/src/resolvers/Mutation/blockUser.ts index 9c3321bf9fd..bd0efb8529d 100644 --- a/src/resolvers/Mutation/blockUser.ts +++ b/src/resolvers/Mutation/blockUser.ts @@ -27,7 +27,7 @@ import { Types } from "mongoose"; export const blockUser: MutationResolvers["blockUser"] = async ( _parent, args, - context + context, ) => { let organization; @@ -50,7 +50,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -63,21 +63,21 @@ export const blockUser: MutationResolvers["blockUser"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // Check whether the user - args.userId is a member of the organization before blocking const userIsOrganizationMember = organization?.members.some( (member) => - member === args.userId || Types.ObjectId(member).equals(args.userId) + member === args.userId || Types.ObjectId(member).equals(args.userId), ); if (!userIsOrganizationMember) { throw new errors.NotFoundError( requestContext.translate(MEMBER_NOT_FOUND_ERROR.MESSAGE), MEMBER_NOT_FOUND_ERROR.CODE, - MEMBER_NOT_FOUND_ERROR.PARAM + MEMBER_NOT_FOUND_ERROR.PARAM, ); } @@ -85,7 +85,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_BLOCKING_SELF.MESSAGE), USER_BLOCKING_SELF.CODE, - USER_BLOCKING_SELF.PARAM + USER_BLOCKING_SELF.PARAM, ); } @@ -93,7 +93,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( await adminCheck(context.userId, organization); const userIsBlocked = organization.blockedUsers.some((blockedUser) => - Types.ObjectId(blockedUser).equals(args.userId) + Types.ObjectId(blockedUser).equals(args.userId), ); // Checks whether user with _id === args.userId is already blocked from organization. @@ -101,7 +101,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -117,7 +117,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -139,7 +139,7 @@ export const blockUser: MutationResolvers["blockUser"] = async ( }, { new: true, - } + }, ) .select(["-password"]) .lean(); diff --git a/src/resolvers/Mutation/cancelMembershipRequest.ts b/src/resolvers/Mutation/cancelMembershipRequest.ts index b48d4a49300..9f4c9495cf8 100644 --- a/src/resolvers/Mutation/cancelMembershipRequest.ts +++ b/src/resolvers/Mutation/cancelMembershipRequest.ts @@ -32,7 +32,7 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest throw new errors.NotFoundError( requestContext.translate(MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE), MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.CODE, - MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM + MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM, ); } @@ -57,7 +57,7 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -70,12 +70,12 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const currentUserCreatedMembershipRequest = currentUser._id.equals( - membershipRequest.user + membershipRequest.user, ); // Checks whether currentUser is the creator of membershipRequest. @@ -83,7 +83,7 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -104,7 +104,7 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -120,7 +120,7 @@ export const cancelMembershipRequest: MutationResolvers["cancelMembershipRequest $pull: { membershipRequests: membershipRequest._id, }, - } + }, ); // Returns the deleted membershipRequest. diff --git a/src/resolvers/Mutation/checkIn.ts b/src/resolvers/Mutation/checkIn.ts index 662d8cb7045..4b01a2bea93 100644 --- a/src/resolvers/Mutation/checkIn.ts +++ b/src/resolvers/Mutation/checkIn.ts @@ -16,7 +16,7 @@ import { Types } from "mongoose"; export const checkIn: MutationResolvers["checkIn"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -26,7 +26,7 @@ export const checkIn: MutationResolvers["checkIn"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -50,20 +50,20 @@ export const checkIn: MutationResolvers["checkIn"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } const isUserEventAdmin = currentEvent.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || Types.ObjectId(admin).equals(context.userId), ); if (!isUserEventAdmin && currentUser.userType !== "SUPERADMIN") { throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -75,7 +75,7 @@ export const checkIn: MutationResolvers["checkIn"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -88,7 +88,7 @@ export const checkIn: MutationResolvers["checkIn"] = async ( throw new errors.ConflictError( requestContext.translate(USER_NOT_REGISTERED_FOR_EVENT.MESSAGE), USER_NOT_REGISTERED_FOR_EVENT.CODE, - USER_NOT_REGISTERED_FOR_EVENT.PARAM + USER_NOT_REGISTERED_FOR_EVENT.PARAM, ); } @@ -96,7 +96,7 @@ export const checkIn: MutationResolvers["checkIn"] = async ( throw new errors.ConflictError( requestContext.translate(USER_ALREADY_CHECKED_IN.MESSAGE), USER_ALREADY_CHECKED_IN.CODE, - USER_ALREADY_CHECKED_IN.PARAM + USER_ALREADY_CHECKED_IN.PARAM, ); } @@ -113,7 +113,7 @@ export const checkIn: MutationResolvers["checkIn"] = async ( }, { checkInId: checkIn._id, - } + }, ); return checkIn.toObject(); diff --git a/src/resolvers/Mutation/createActionItem.ts b/src/resolvers/Mutation/createActionItem.ts index c2ec83ff93f..43626447044 100644 --- a/src/resolvers/Mutation/createActionItem.ts +++ b/src/resolvers/Mutation/createActionItem.ts @@ -32,7 +32,7 @@ import { Types } from "mongoose"; export const createActionItem: MutationResolvers["createActionItem"] = async ( _parent, args, - context + context, ): Promise => { const currentUser = await User.findOne({ _id: context.userId, @@ -43,7 +43,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -56,7 +56,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -69,7 +69,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE), ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM, ); } @@ -77,7 +77,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( asigneeIsOrganizationMember = assignee.joinedOrganizations.some( (organizationId) => organizationId === actionItemCategory.organizationId || - Types.ObjectId(organizationId).equals(actionItemCategory.organizationId) + Types.ObjectId(organizationId).equals(actionItemCategory.organizationId), ); // Checks if the asignee is a member of the organization @@ -85,7 +85,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_MEMBER_FOR_ORGANIZATION.MESSAGE), USER_NOT_MEMBER_FOR_ORGANIZATION.CODE, - USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM + USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM, ); } @@ -113,14 +113,15 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } // Checks if the currUser is an admin of the event currentUserIsEventAdmin = currEvent.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || + Types.ObjectId(admin).equals(context.userId), ); } @@ -128,7 +129,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( const currentUserIsOrgAdmin = currentUser.adminFor.some( (ogranizationId) => ogranizationId === actionItemCategory.organizationId || - Types.ObjectId(ogranizationId).equals(actionItemCategory.organizationId) + Types.ObjectId(ogranizationId).equals(actionItemCategory.organizationId), ); // Checks whether currentUser with _id === context.userId is authorized for the operation. @@ -140,7 +141,7 @@ export const createActionItem: MutationResolvers["createActionItem"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/createActionItemCategory.ts b/src/resolvers/Mutation/createActionItemCategory.ts index 2df722f91af..aa66ce9e51e 100644 --- a/src/resolvers/Mutation/createActionItemCategory.ts +++ b/src/resolvers/Mutation/createActionItemCategory.ts @@ -35,7 +35,7 @@ export const createActionItemCategory: MutationResolvers["createActionItemCatego throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -60,7 +60,7 @@ export const createActionItemCategory: MutationResolvers["createActionItemCatego throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -77,7 +77,7 @@ export const createActionItemCategory: MutationResolvers["createActionItemCatego throw new errors.ConflictError( requestContext.translate(ACTION_ITEM_CATEGORY_ALREADY_EXISTS.MESSAGE), ACTION_ITEM_CATEGORY_ALREADY_EXISTS.CODE, - ACTION_ITEM_CATEGORY_ALREADY_EXISTS.PARAM + ACTION_ITEM_CATEGORY_ALREADY_EXISTS.PARAM, ); } diff --git a/src/resolvers/Mutation/createAdmin.ts b/src/resolvers/Mutation/createAdmin.ts index 8a558a76ff2..b7680979cf3 100644 --- a/src/resolvers/Mutation/createAdmin.ts +++ b/src/resolvers/Mutation/createAdmin.ts @@ -27,7 +27,7 @@ import { Types } from "mongoose"; export const createAdmin: MutationResolvers["createAdmin"] = async ( _parent, args, - context + context, ) => { let organization; @@ -50,7 +50,7 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } // Checks whether the current user is a superAdmin @@ -61,7 +61,7 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } superAdminCheck(currentUser); @@ -75,12 +75,12 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const userIsOrganizationMember = organization.members.some((member) => - Types.ObjectId(member).equals(args.data.userId) + Types.ObjectId(member).equals(args.data.userId), ); // Checks whether user with _id === args.data.userId is not a member of organization. @@ -88,12 +88,12 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_MEMBER_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_MEMBER_NOT_FOUND_ERROR.CODE, - ORGANIZATION_MEMBER_NOT_FOUND_ERROR.PARAM + ORGANIZATION_MEMBER_NOT_FOUND_ERROR.PARAM, ); } const userIsOrganizationAdmin = organization.admins.some((admin) => - Types.ObjectId(admin).equals(args.data.userId) + Types.ObjectId(admin).equals(args.data.userId), ); // Checks whether user with _id === args.data.userId is already an admin of organization. @@ -101,7 +101,7 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -117,7 +117,7 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -139,7 +139,7 @@ export const createAdmin: MutationResolvers["createAdmin"] = async ( }, { new: true, - } + }, ) .select(["-password"]) .lean(); diff --git a/src/resolvers/Mutation/createComment.ts b/src/resolvers/Mutation/createComment.ts index 32495a6c791..44521a12c89 100644 --- a/src/resolvers/Mutation/createComment.ts +++ b/src/resolvers/Mutation/createComment.ts @@ -17,7 +17,7 @@ import { cachePosts } from "../../services/PostCache/cachePosts"; export const createComment: MutationResolvers["createComment"] = async ( _parent, args, - context + context, ) => { // Check if the provided post exists const postExists = await Post.exists({ @@ -28,7 +28,7 @@ export const createComment: MutationResolvers["createComment"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } @@ -53,7 +53,7 @@ export const createComment: MutationResolvers["createComment"] = async ( }, { new: true, - } + }, ); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/createDirectChat.ts b/src/resolvers/Mutation/createDirectChat.ts index 9c32226364d..7eec05be770 100644 --- a/src/resolvers/Mutation/createDirectChat.ts +++ b/src/resolvers/Mutation/createDirectChat.ts @@ -20,7 +20,7 @@ import { cacheOrganizations } from "../../services/OrganizationCache/cacheOrgani export const createDirectChat: MutationResolvers["createDirectChat"] = async ( _parent, args, - context + context, ) => { let organization; @@ -43,7 +43,7 @@ export const createDirectChat: MutationResolvers["createDirectChat"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -61,7 +61,7 @@ export const createDirectChat: MutationResolvers["createDirectChat"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/createDonation.ts b/src/resolvers/Mutation/createDonation.ts index 58f17a436a9..d082f85bb1d 100644 --- a/src/resolvers/Mutation/createDonation.ts +++ b/src/resolvers/Mutation/createDonation.ts @@ -10,7 +10,7 @@ import { Donation } from "../../models"; */ export const createDonation: MutationResolvers["createDonation"] = async ( _parent, - args + args, ) => { const createdDonation = await Donation.create({ amount: args.amount, diff --git a/src/resolvers/Mutation/createEvent.ts b/src/resolvers/Mutation/createEvent.ts index d05e10a43e4..9705110c9d5 100644 --- a/src/resolvers/Mutation/createEvent.ts +++ b/src/resolvers/Mutation/createEvent.ts @@ -30,7 +30,7 @@ import { Weekly, Once } from "../../helpers/eventInstances"; export const createEvent: MutationResolvers["createEvent"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -41,7 +41,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -54,16 +54,16 @@ export const createEvent: MutationResolvers["createEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } const userCreatedOrganization = currentUser.createdOrganizations.some( - (createdOrganization) => createdOrganization.equals(organization._id) + (createdOrganization) => createdOrganization.equals(organization._id), ); const userJoinedOrganization = currentUser.joinedOrganizations.some( - (joinedOrganization) => joinedOrganization.equals(organization._id) + (joinedOrganization) => joinedOrganization.equals(organization._id), ); // Checks whether currentUser neither created nor joined the organization. @@ -77,7 +77,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( throw new errors.UnauthorizedError( requestContext.translate(ORGANIZATION_NOT_AUTHORIZED_ERROR.MESSAGE), ORGANIZATION_NOT_AUTHORIZED_ERROR.CODE, - ORGANIZATION_NOT_AUTHORIZED_ERROR.PARAM + ORGANIZATION_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -85,41 +85,41 @@ export const createEvent: MutationResolvers["createEvent"] = async ( const validationResultTitle = isValidString(args.data?.title ?? "", 256); const validationResultDescription = isValidString( args.data?.description ?? "", - 500 + 500, ); const validationResultLocation = isValidString(args.data?.location ?? "", 50); if (!validationResultTitle.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultDescription.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultLocation.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } const compareDatesResult = compareDates( args.data?.startDate, - args.data?.endDate + args.data?.endDate, ); if (compareDatesResult !== "") { throw new errors.InputValidationError( requestContext.translate(compareDatesResult), - compareDatesResult + compareDatesResult, ); } @@ -137,7 +137,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( args, currentUser, organization, - session + session, ); for (const event of createdEvent) { @@ -152,7 +152,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( args, currentUser, organization, - session + session, ); for (const event of createdEvent) { @@ -167,7 +167,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( args, currentUser, organization, - session + session, ); for (const event of createdEvent) { @@ -193,7 +193,7 @@ export const createEvent: MutationResolvers["createEvent"] = async ( async function associateEventWithUser( currentUser: InterfaceUser, createdEvent: InterfaceEvent, - session: mongoose.ClientSession + session: mongoose.ClientSession, ): Promise { await EventAttendee.create( [ @@ -202,7 +202,7 @@ async function associateEventWithUser( eventId: createdEvent._id, }, ], - { session } + { session }, ); await User.updateOne( @@ -216,6 +216,6 @@ async function associateEventWithUser( registeredEvents: createdEvent._id, }, }, - { session } + { session }, ); } diff --git a/src/resolvers/Mutation/createGroupChat.ts b/src/resolvers/Mutation/createGroupChat.ts index 53835f8d457..b6eb9112706 100644 --- a/src/resolvers/Mutation/createGroupChat.ts +++ b/src/resolvers/Mutation/createGroupChat.ts @@ -20,7 +20,7 @@ import { findOrganizationsInCache } from "../../services/OrganizationCache/findO export const createGroupChat: MutationResolvers["createGroupChat"] = async ( _parent, args, - context + context, ) => { let organization; @@ -43,7 +43,7 @@ export const createGroupChat: MutationResolvers["createGroupChat"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -61,7 +61,7 @@ export const createGroupChat: MutationResolvers["createGroupChat"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/createMember.ts b/src/resolvers/Mutation/createMember.ts index d55623a899e..6e380236212 100644 --- a/src/resolvers/Mutation/createMember.ts +++ b/src/resolvers/Mutation/createMember.ts @@ -24,7 +24,7 @@ import { cacheOrganizations } from "../../services/OrganizationCache/cacheOrgani export const createMember: MutationResolvers["createMember"] = async ( _parent, args, - context + context, ) => { // Checks whether the current user is a superAdmin const currentUser = await User.findOne({ @@ -35,7 +35,7 @@ export const createMember: MutationResolvers["createMember"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } superAdminCheck(currentUser); @@ -61,7 +61,7 @@ export const createMember: MutationResolvers["createMember"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -74,12 +74,12 @@ export const createMember: MutationResolvers["createMember"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const userIsOrganizationMember = organization?.members.some((member) => - member.equals(user._id) + member.equals(user._id), ); // Checks whether user with _id === args.input.userId is already an member of organization. @@ -87,7 +87,7 @@ export const createMember: MutationResolvers["createMember"] = async ( throw new errors.NotFoundError( requestContext.translate(MEMBER_NOT_FOUND_ERROR.MESSAGE), MEMBER_NOT_FOUND_ERROR.CODE, - MEMBER_NOT_FOUND_ERROR.PARAM + MEMBER_NOT_FOUND_ERROR.PARAM, ); } @@ -103,7 +103,7 @@ export const createMember: MutationResolvers["createMember"] = async ( }, { new: true, - } + }, ); // add user's id to members list on organization and return it. @@ -118,7 +118,7 @@ export const createMember: MutationResolvers["createMember"] = async ( }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/src/resolvers/Mutation/createMessageChat.ts b/src/resolvers/Mutation/createMessageChat.ts index 5d828e9b4da..5e7cba995a7 100644 --- a/src/resolvers/Mutation/createMessageChat.ts +++ b/src/resolvers/Mutation/createMessageChat.ts @@ -15,7 +15,7 @@ import { USER_NOT_FOUND_ERROR } from "../../constants"; export const createMessageChat: MutationResolvers["createMessageChat"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -30,7 +30,7 @@ export const createMessageChat: MutationResolvers["createMessageChat"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/createOrganization.ts b/src/resolvers/Mutation/createOrganization.ts index 46ab3079464..df7aa6db1ee 100644 --- a/src/resolvers/Mutation/createOrganization.ts +++ b/src/resolvers/Mutation/createOrganization.ts @@ -58,17 +58,17 @@ export const createOrganization: MutationResolvers["createOrganization"] = if (!validationResultName.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultDescription.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultAddress.isAddressValid) { @@ -108,7 +108,7 @@ export const createOrganization: MutationResolvers["createOrganization"] = createdOrganizations: createdOrganization._id, adminFor: createdOrganization._id, }, - } + }, ); // Returns createdOrganization. diff --git a/src/resolvers/Mutation/createPlugin.ts b/src/resolvers/Mutation/createPlugin.ts index da1be20aa0e..290d4db17cd 100644 --- a/src/resolvers/Mutation/createPlugin.ts +++ b/src/resolvers/Mutation/createPlugin.ts @@ -12,7 +12,7 @@ import { Plugin } from "../../models"; export const createPlugin: MutationResolvers["createPlugin"] = async ( _parent, args, - context + context, ) => { // Creates new plugin. const createdPlugin = await Plugin.create({ diff --git a/src/resolvers/Mutation/createPost.ts b/src/resolvers/Mutation/createPost.ts index 10f4b782eed..49aa0a4fe98 100644 --- a/src/resolvers/Mutation/createPost.ts +++ b/src/resolvers/Mutation/createPost.ts @@ -28,7 +28,7 @@ import { cachePosts } from "../../services/PostCache/cachePosts"; export const createPost: MutationResolvers["createPost"] = async ( _parent, args, - context + context, ) => { // Get the current user const currentUser = await User.findOne({ @@ -40,7 +40,7 @@ export const createPost: MutationResolvers["createPost"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -65,7 +65,7 @@ export const createPost: MutationResolvers["createPost"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -87,12 +87,12 @@ export const createPost: MutationResolvers["createPost"] = async ( if (args.data?.title && !args.data.pinned) { throw new errors.InputValidationError( requestContext.translate(POST_NEEDS_TO_BE_PINNED.MESSAGE), - POST_NEEDS_TO_BE_PINNED.CODE + POST_NEEDS_TO_BE_PINNED.CODE, ); } else if (!args.data?.title && args.data.pinned) { throw new errors.InputValidationError( requestContext.translate(PLEASE_PROVIDE_TITLE.MESSAGE), - PLEASE_PROVIDE_TITLE.CODE + PLEASE_PROVIDE_TITLE.CODE, ); } @@ -103,17 +103,17 @@ export const createPost: MutationResolvers["createPost"] = async ( if (!validationResultTitle.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultText.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } } @@ -121,7 +121,7 @@ export const createPost: MutationResolvers["createPost"] = async ( if (args.data.pinned) { // Check if the user has privileges to pin the post const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organizationId) => organizationId.equals(args.data.organizationId) + (organizationId) => organizationId.equals(args.data.organizationId), ); if (currentUser?.userType) { if ( @@ -131,7 +131,7 @@ export const createPost: MutationResolvers["createPost"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_TO_PIN.MESSAGE), USER_NOT_AUTHORIZED_TO_PIN.CODE, - USER_NOT_AUTHORIZED_TO_PIN.PARAM + USER_NOT_AUTHORIZED_TO_PIN.PARAM, ); } } @@ -162,7 +162,7 @@ export const createPost: MutationResolvers["createPost"] = async ( }, { new: true, - } + }, ); await cacheOrganizations([updatedOrganizaiton!]); diff --git a/src/resolvers/Mutation/createSampleOrganization.ts b/src/resolvers/Mutation/createSampleOrganization.ts index 86fd355f168..c95bf9903ae 100644 --- a/src/resolvers/Mutation/createSampleOrganization.ts +++ b/src/resolvers/Mutation/createSampleOrganization.ts @@ -22,7 +22,7 @@ export const createSampleOrganization: MutationResolvers["createSampleOrganizati throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -35,7 +35,7 @@ export const createSampleOrganization: MutationResolvers["createSampleOrganizati throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -47,7 +47,7 @@ export const createSampleOrganization: MutationResolvers["createSampleOrganizati throw new errors.UnauthorizedError( requestContext.translate(SAMPLE_ORGANIZATION_ALREADY_EXISTS.MESSAGE), SAMPLE_ORGANIZATION_ALREADY_EXISTS.CODE, - SAMPLE_ORGANIZATION_ALREADY_EXISTS.PARAM + SAMPLE_ORGANIZATION_ALREADY_EXISTS.PARAM, ); } diff --git a/src/resolvers/Mutation/createUserTag.ts b/src/resolvers/Mutation/createUserTag.ts index 6df7a899df5..12b9d7830db 100644 --- a/src/resolvers/Mutation/createUserTag.ts +++ b/src/resolvers/Mutation/createUserTag.ts @@ -13,7 +13,7 @@ import { export const createUserTag: MutationResolvers["createUserTag"] = async ( _parent, args, - context + context, ) => { // Get the current user const currentUser = await User.findOne({ @@ -25,7 +25,7 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -38,13 +38,13 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } // Check if the user has privileges to create the tag const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organizationId) => organizationId.equals(args.input.organizationId) + (organizationId) => organizationId.equals(args.input.organizationId), ); if ( @@ -54,7 +54,7 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_TO_CREATE_TAG.MESSAGE), USER_NOT_AUTHORIZED_TO_CREATE_TAG.CODE, - USER_NOT_AUTHORIZED_TO_CREATE_TAG.PARAM + USER_NOT_AUTHORIZED_TO_CREATE_TAG.PARAM, ); } @@ -69,7 +69,7 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(TAG_NOT_FOUND.MESSAGE), TAG_NOT_FOUND.CODE, - TAG_NOT_FOUND.PARAM + TAG_NOT_FOUND.PARAM, ); } @@ -81,7 +81,7 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(INCORRECT_TAG_INPUT.MESSAGE), INCORRECT_TAG_INPUT.CODE, - INCORRECT_TAG_INPUT.PARAM + INCORRECT_TAG_INPUT.PARAM, ); } } @@ -95,7 +95,7 @@ export const createUserTag: MutationResolvers["createUserTag"] = async ( throw new errors.ConflictError( requestContext.translate(TAG_ALREADY_EXISTS.MESSAGE), TAG_ALREADY_EXISTS.CODE, - TAG_ALREADY_EXISTS.PARAM + TAG_ALREADY_EXISTS.PARAM, ); } diff --git a/src/resolvers/Mutation/forgotPassword.ts b/src/resolvers/Mutation/forgotPassword.ts index da39b1b0c45..513dc1f3bc6 100644 --- a/src/resolvers/Mutation/forgotPassword.ts +++ b/src/resolvers/Mutation/forgotPassword.ts @@ -16,7 +16,7 @@ import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; */ export const forgotPassword: MutationResolvers["forgotPassword"] = async ( _parent, - args + args, ) => { const { userOtp, newPassword, otpToken } = args.data; @@ -43,7 +43,7 @@ export const forgotPassword: MutationResolvers["forgotPassword"] = async ( }, { password: hashedPassword, - } + }, ); // Returns true if operation is successful. diff --git a/src/resolvers/Mutation/joinPublicOrganization.ts b/src/resolvers/Mutation/joinPublicOrganization.ts index 2f24dd36e97..cacc6703011 100644 --- a/src/resolvers/Mutation/joinPublicOrganization.ts +++ b/src/resolvers/Mutation/joinPublicOrganization.ts @@ -45,7 +45,7 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -54,7 +54,7 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } const currentUserExists = await User.exists({ @@ -65,12 +65,12 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsOrganizationMember = organization.members.some( - (member) => Types.ObjectId(member).equals(context.userId) + (member) => Types.ObjectId(member).equals(context.userId), ); // Checks whether currentUser with _id === context.userId is already a member of organzation. @@ -78,7 +78,7 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] throw new errors.ConflictError( requestContext.translate(USER_ALREADY_MEMBER_ERROR.MESSAGE), USER_ALREADY_MEMBER_ERROR.CODE, - USER_ALREADY_MEMBER_ERROR.PARAM + USER_ALREADY_MEMBER_ERROR.PARAM, ); } @@ -94,7 +94,7 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -116,7 +116,7 @@ export const joinPublicOrganization: MutationResolvers["joinPublicOrganization"] }, { new: true, - } + }, ) .select(["-password"]) .populate("joinedOrganizations") diff --git a/src/resolvers/Mutation/leaveOrganization.ts b/src/resolvers/Mutation/leaveOrganization.ts index d8b72ba98ed..e58c7c5c8eb 100644 --- a/src/resolvers/Mutation/leaveOrganization.ts +++ b/src/resolvers/Mutation/leaveOrganization.ts @@ -24,7 +24,7 @@ import { Types } from "mongoose"; export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( _parent, args, - context + context, ) => { let organization; @@ -47,7 +47,7 @@ export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -60,12 +60,12 @@ export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsOrganizationMember = organization.members.some((member) => - Types.ObjectId(member).equals(currentUser?._id) + Types.ObjectId(member).equals(currentUser?._id), ); // Checks whether currentUser is not a member of organzation. @@ -73,7 +73,7 @@ export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( throw new errors.ConflictError( requestContext.translate(MEMBER_NOT_FOUND_ERROR.MESSAGE), MEMBER_NOT_FOUND_ERROR.CODE, - MEMBER_NOT_FOUND_ERROR.PARAM + MEMBER_NOT_FOUND_ERROR.PARAM, ); } @@ -90,7 +90,7 @@ export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -112,7 +112,7 @@ export const leaveOrganization: MutationResolvers["leaveOrganization"] = async ( }, { new: true, - } + }, ) .select(["-password"]) .lean(); diff --git a/src/resolvers/Mutation/likeComment.ts b/src/resolvers/Mutation/likeComment.ts index 86c4df47cd2..dc2a11b39a3 100644 --- a/src/resolvers/Mutation/likeComment.ts +++ b/src/resolvers/Mutation/likeComment.ts @@ -18,7 +18,7 @@ import { cacheComments } from "../../services/CommentCache/cacheComments"; export const likeComment: MutationResolvers["likeComment"] = async ( _parent, args, - context + context, ) => { let comment; @@ -41,12 +41,12 @@ export const likeComment: MutationResolvers["likeComment"] = async ( throw new errors.NotFoundError( requestContext.translate(COMMENT_NOT_FOUND_ERROR.MESSAGE), COMMENT_NOT_FOUND_ERROR.CODE, - COMMENT_NOT_FOUND_ERROR.PARAM + COMMENT_NOT_FOUND_ERROR.PARAM, ); } const currentUserHasLikedComment = comment.likedBy.some((likedByUser) => - likedByUser.equals(context.userId) + likedByUser.equals(context.userId), ); // Checks whether currentUser with _id === context.userId has not already liked the comment. @@ -69,7 +69,7 @@ export const likeComment: MutationResolvers["likeComment"] = async ( }, { new: true, - } + }, ).lean(); if (updatedComment !== null) { diff --git a/src/resolvers/Mutation/likePost.ts b/src/resolvers/Mutation/likePost.ts index 2f63eca5e97..638a8b9ccea 100644 --- a/src/resolvers/Mutation/likePost.ts +++ b/src/resolvers/Mutation/likePost.ts @@ -18,7 +18,7 @@ import { cachePosts } from "../../services/PostCache/cachePosts"; export const likePost: MutationResolvers["likePost"] = async ( _parent, args, - context + context, ) => { let post; @@ -41,12 +41,12 @@ export const likePost: MutationResolvers["likePost"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } const currentUserHasLikedPost = post.likedBy.some((likedByUser) => - likedByUser.equals(context.userId) + likedByUser.equals(context.userId), ); // Checks whether currentUser with _id === context.userId has not already liked the post. @@ -69,7 +69,7 @@ export const likePost: MutationResolvers["likePost"] = async ( }, { new: true, - } + }, ).lean(); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/login.ts b/src/resolvers/Mutation/login.ts index 94ae28496e9..e6f7509f49c 100644 --- a/src/resolvers/Mutation/login.ts +++ b/src/resolvers/Mutation/login.ts @@ -32,12 +32,12 @@ export const login: MutationResolvers["login"] = async (_parent, args) => { throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const isPasswordValid = await bcrypt.compare( args.data.password, - user.password + user.password, ); // Checks whether password is invalid. if (isPasswordValid === false) { @@ -49,7 +49,7 @@ export const login: MutationResolvers["login"] = async (_parent, args) => { param: INVALID_CREDENTIALS_ERROR.PARAM, }, ], - requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE) + requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE), ); } const accessToken = await createAccessToken(user); @@ -69,13 +69,13 @@ export const login: MutationResolvers["login"] = async (_parent, args) => { }, { userType: "SUPERADMIN", - } + }, ); } await User.findOneAndUpdate( { _id: user._id }, - { token: refreshToken, $inc: { tokenVersion: 1 } } + { token: refreshToken, $inc: { tokenVersion: 1 } }, ); // Assigns new value with populated fields to user object. diff --git a/src/resolvers/Mutation/logout.ts b/src/resolvers/Mutation/logout.ts index e4a3710e194..eae004ad24d 100644 --- a/src/resolvers/Mutation/logout.ts +++ b/src/resolvers/Mutation/logout.ts @@ -13,7 +13,7 @@ import { User } from "../../models"; export const logout: MutationResolvers["logout"] = async ( _parent, _args, - context + context, ) => { // Sets token field of currentUser with _id === context.userId to null. await User.updateOne( @@ -24,7 +24,7 @@ export const logout: MutationResolvers["logout"] = async ( $set: { token: null, }, - } + }, ); // Returns true if the operation is successful. diff --git a/src/resolvers/Mutation/otp.ts b/src/resolvers/Mutation/otp.ts index 066c3ba5db7..be8c0588177 100644 --- a/src/resolvers/Mutation/otp.ts +++ b/src/resolvers/Mutation/otp.ts @@ -36,7 +36,7 @@ export const otp: MutationResolvers["otp"] = async (_parent, args) => { ACCESS_TOKEN_SECRET as string, { expiresIn: "15m", - } + }, ); const subject = "OTP for Talawa-admin forgot password"; diff --git a/src/resolvers/Mutation/recaptcha.ts b/src/resolvers/Mutation/recaptcha.ts index 0cb3101edfb..13a8edf882a 100644 --- a/src/resolvers/Mutation/recaptcha.ts +++ b/src/resolvers/Mutation/recaptcha.ts @@ -9,10 +9,10 @@ import type { MutationResolvers } from "../../types/generatedGraphQLTypes"; */ export const recaptcha: MutationResolvers["recaptcha"] = async ( _parent, - args + args, ) => { const response = await axios.post( - `https://www.google.com/recaptcha/api/siteverify?secret=${RECAPTCHA_SECRET_KEY}&response=${args.data.recaptchaToken}` + `https://www.google.com/recaptcha/api/siteverify?secret=${RECAPTCHA_SECRET_KEY}&response=${args.data.recaptchaToken}`, ); return response.data.success; diff --git a/src/resolvers/Mutation/refreshToken.ts b/src/resolvers/Mutation/refreshToken.ts index ad98d6ccd5d..3dca437b5c5 100644 --- a/src/resolvers/Mutation/refreshToken.ts +++ b/src/resolvers/Mutation/refreshToken.ts @@ -22,7 +22,7 @@ import { */ export const refreshToken: MutationResolvers["refreshToken"] = async ( _parent, - args + args, ) => { // This route should not be protected because the access token will be expired. if (!args.refreshToken || typeof args.refreshToken !== "string") { @@ -30,19 +30,19 @@ export const refreshToken: MutationResolvers["refreshToken"] = async ( [ { message: requestContext.translate( - INVALID_REFRESH_TOKEN_ERROR.MESSAGE + INVALID_REFRESH_TOKEN_ERROR.MESSAGE, ), code: INVALID_REFRESH_TOKEN_ERROR.CODE, param: INVALID_REFRESH_TOKEN_ERROR.PARAM, }, ], - requestContext.translate(INVALID_REFRESH_TOKEN_ERROR.MESSAGE) + requestContext.translate(INVALID_REFRESH_TOKEN_ERROR.MESSAGE), ); } const jwtPayload: InterfaceJwtTokenPayload = jwt.verify( args.refreshToken, - REFRESH_TOKEN_SECRET as string + REFRESH_TOKEN_SECRET as string, ) as InterfaceJwtTokenPayload; // The refresh token received is valid so we can send a new access token @@ -55,7 +55,7 @@ export const refreshToken: MutationResolvers["refreshToken"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -68,13 +68,13 @@ export const refreshToken: MutationResolvers["refreshToken"] = async ( [ { message: requestContext.translate( - INVALID_REFRESH_TOKEN_ERROR.MESSAGE + INVALID_REFRESH_TOKEN_ERROR.MESSAGE, ), code: INVALID_REFRESH_TOKEN_ERROR.CODE, param: INVALID_REFRESH_TOKEN_ERROR.PARAM, }, ], - requestContext.translate(INVALID_REFRESH_TOKEN_ERROR.MESSAGE) + requestContext.translate(INVALID_REFRESH_TOKEN_ERROR.MESSAGE), ); } diff --git a/src/resolvers/Mutation/registerForEvent.ts b/src/resolvers/Mutation/registerForEvent.ts index fcd14b80a89..c35f716b1a6 100644 --- a/src/resolvers/Mutation/registerForEvent.ts +++ b/src/resolvers/Mutation/registerForEvent.ts @@ -24,7 +24,7 @@ import { cacheEvents } from "../../services/EventCache/cacheEvents"; export const registerForEvent: MutationResolvers["registerForEvent"] = async ( _parent, args, - context + context, ) => { let event: InterfaceEvent | null; @@ -47,7 +47,7 @@ export const registerForEvent: MutationResolvers["registerForEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } @@ -60,7 +60,7 @@ export const registerForEvent: MutationResolvers["registerForEvent"] = async ( throw new errors.InputValidationError( requestContext.translate(REGISTRANT_ALREADY_EXIST_ERROR.MESSAGE), REGISTRANT_ALREADY_EXIST_ERROR.CODE, - REGISTRANT_ALREADY_EXIST_ERROR.PARAM + REGISTRANT_ALREADY_EXIST_ERROR.PARAM, ); } @@ -73,7 +73,7 @@ export const registerForEvent: MutationResolvers["registerForEvent"] = async ( $push: { registeredEvents: event._id, }, - } + }, ); await EventAttendee.create({ diff --git a/src/resolvers/Mutation/rejectAdmin.ts b/src/resolvers/Mutation/rejectAdmin.ts index cbf4073b4e7..e5035763a33 100644 --- a/src/resolvers/Mutation/rejectAdmin.ts +++ b/src/resolvers/Mutation/rejectAdmin.ts @@ -17,7 +17,7 @@ import { superAdminCheck } from "../../utilities"; export const rejectAdmin: MutationResolvers["rejectAdmin"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -28,7 +28,7 @@ export const rejectAdmin: MutationResolvers["rejectAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -44,7 +44,7 @@ export const rejectAdmin: MutationResolvers["rejectAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -57,7 +57,7 @@ export const rejectAdmin: MutationResolvers["rejectAdmin"] = async ( $set: { adminApproved: false, }, - } + }, ); // Returns true if operation is successful. diff --git a/src/resolvers/Mutation/rejectMembershipRequest.ts b/src/resolvers/Mutation/rejectMembershipRequest.ts index 838d3263a51..98f6e13e4f2 100644 --- a/src/resolvers/Mutation/rejectMembershipRequest.ts +++ b/src/resolvers/Mutation/rejectMembershipRequest.ts @@ -34,7 +34,7 @@ export const rejectMembershipRequest: MutationResolvers["rejectMembershipRequest throw new errors.NotFoundError( requestContext.translate(MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE), MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.CODE, - MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM + MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM, ); } @@ -43,7 +43,7 @@ export const rejectMembershipRequest: MutationResolvers["rejectMembershipRequest throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -52,7 +52,7 @@ export const rejectMembershipRequest: MutationResolvers["rejectMembershipRequest throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -76,7 +76,7 @@ export const rejectMembershipRequest: MutationResolvers["rejectMembershipRequest }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -92,7 +92,7 @@ export const rejectMembershipRequest: MutationResolvers["rejectMembershipRequest $pull: { membershipRequests: membershipRequest._id, }, - } + }, ); // Returns deleted membershipRequest. diff --git a/src/resolvers/Mutation/removeActionItem.ts b/src/resolvers/Mutation/removeActionItem.ts index ae1c023213d..c080d15a303 100644 --- a/src/resolvers/Mutation/removeActionItem.ts +++ b/src/resolvers/Mutation/removeActionItem.ts @@ -26,7 +26,7 @@ import { cacheEvents } from "../../services/EventCache/cacheEvents"; export const removeActionItem: MutationResolvers["removeActionItem"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -37,7 +37,7 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -52,7 +52,7 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(ACTION_ITEM_NOT_FOUND_ERROR.MESSAGE), ACTION_ITEM_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_NOT_FOUND_ERROR.PARAM, ); } @@ -60,8 +60,8 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( (ogranizationId) => ogranizationId === actionItem.actionItemCategoryId.organizationId || Types.ObjectId(ogranizationId).equals( - actionItem.actionItemCategoryId.organizationId - ) + actionItem.actionItemCategoryId.organizationId, + ), ); let currentUserIsEventAdmin = false; @@ -88,14 +88,15 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } // Checks if the currUser is an admin of the event currentUserIsEventAdmin = currEvent.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || + Types.ObjectId(admin).equals(context.userId), ); } @@ -108,7 +109,7 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/removeAdmin.ts b/src/resolvers/Mutation/removeAdmin.ts index 68f29209201..9170f92749d 100644 --- a/src/resolvers/Mutation/removeAdmin.ts +++ b/src/resolvers/Mutation/removeAdmin.ts @@ -26,7 +26,7 @@ import { Types } from "mongoose"; export const removeAdmin: MutationResolvers["removeAdmin"] = async ( _parent, args, - context + context, ) => { let organization: InterfaceOrganization; @@ -49,7 +49,7 @@ export const removeAdmin: MutationResolvers["removeAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -66,20 +66,20 @@ export const removeAdmin: MutationResolvers["removeAdmin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // Checks whether user is an admin of the organization. const userIsOrganizationAdmin = organization.admins.some((admin) => - Types.ObjectId(admin).equals(user._id) + Types.ObjectId(admin).equals(user._id), ); if (!userIsOrganizationAdmin) { throw new errors.UnauthorizedError( requestContext.translate(`${USER_NOT_ORGANIZATION_ADMIN.MESSAGE}`), USER_NOT_ORGANIZATION_ADMIN.CODE, - USER_NOT_ORGANIZATION_ADMIN.PARAM + USER_NOT_ORGANIZATION_ADMIN.PARAM, ); } @@ -94,13 +94,13 @@ export const removeAdmin: MutationResolvers["removeAdmin"] = async ( { $set: { admins: organization.admins.filter( - (admin) => admin.toString() !== user!._id.toString() + (admin) => admin.toString() !== user!._id.toString(), ), }, }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -116,13 +116,13 @@ export const removeAdmin: MutationResolvers["removeAdmin"] = async ( $set: { adminFor: user.adminFor.filter( (adminForOrganization) => - adminForOrganization.toString() !== organization._id.toString() + adminForOrganization.toString() !== organization._id.toString(), ), }, }, { new: true, - } + }, ) .select(["-password"]) .lean(); diff --git a/src/resolvers/Mutation/removeAdvertisement.ts b/src/resolvers/Mutation/removeAdvertisement.ts index 9c9fa0059ca..c664731332d 100644 --- a/src/resolvers/Mutation/removeAdvertisement.ts +++ b/src/resolvers/Mutation/removeAdvertisement.ts @@ -15,7 +15,7 @@ export const removeAdvertisement: MutationResolvers["removeAdvertisement"] = throw new errors.NotFoundError( requestContext.translate(ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE), ADVERTISEMENT_NOT_FOUND_ERROR.CODE, - ADVERTISEMENT_NOT_FOUND_ERROR.PARAM + ADVERTISEMENT_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/removeComment.ts b/src/resolvers/Mutation/removeComment.ts index 48dd672ca31..0954bbbf713 100644 --- a/src/resolvers/Mutation/removeComment.ts +++ b/src/resolvers/Mutation/removeComment.ts @@ -26,7 +26,7 @@ import { cachePosts } from "../../services/PostCache/cachePosts"; export const removeComment: MutationResolvers["removeComment"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -37,7 +37,7 @@ export const removeComment: MutationResolvers["removeComment"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -60,12 +60,12 @@ export const removeComment: MutationResolvers["removeComment"] = async ( throw new errors.NotFoundError( requestContext.translate(COMMENT_NOT_FOUND_ERROR.MESSAGE), COMMENT_NOT_FOUND_ERROR.CODE, - COMMENT_NOT_FOUND_ERROR.PARAM + COMMENT_NOT_FOUND_ERROR.PARAM, ); } const isCurrentUserAdminOfOrganization = currentUser.adminFor.some( - (organization) => organization.equals(comment.postId.organization) + (organization) => organization.equals(comment.postId.organization), ); // Checks whether currentUser with _id === context.userId has the authorization to delete the comment @@ -77,7 +77,7 @@ export const removeComment: MutationResolvers["removeComment"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -94,7 +94,7 @@ export const removeComment: MutationResolvers["removeComment"] = async ( }, { new: true, - } + }, ).lean(); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/removeDirectChat.ts b/src/resolvers/Mutation/removeDirectChat.ts index 9d386890271..a1401eff795 100644 --- a/src/resolvers/Mutation/removeDirectChat.ts +++ b/src/resolvers/Mutation/removeDirectChat.ts @@ -22,7 +22,7 @@ import { cacheOrganizations } from "../../services/OrganizationCache/cacheOrgani export const removeDirectChat: MutationResolvers["removeDirectChat"] = async ( _parent, args, - context + context, ) => { let organization; @@ -45,7 +45,7 @@ export const removeDirectChat: MutationResolvers["removeDirectChat"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -58,7 +58,7 @@ export const removeDirectChat: MutationResolvers["removeDirectChat"] = async ( throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/removeEvent.ts b/src/resolvers/Mutation/removeEvent.ts index 63322f847cc..9da1872f5ef 100644 --- a/src/resolvers/Mutation/removeEvent.ts +++ b/src/resolvers/Mutation/removeEvent.ts @@ -24,7 +24,7 @@ import { cacheEvents } from "../../services/EventCache/cacheEvents"; export const removeEvent: MutationResolvers["removeEvent"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -35,7 +35,7 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -60,18 +60,18 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } // Boolean to determine whether user is an admin of organization. const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(event?.organization) + (organization) => organization.equals(event?.organization), ); // Boolean to determine whether user is an admin of event. const currentUserIsEventAdmin = event.admins.some((admin) => - admin.equals(currentUser._id) + admin.equals(currentUser._id), ); // Checks whether currentUser cannot delete event. @@ -85,7 +85,7 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -97,7 +97,7 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( $pull: { createdEvents: event._id, }, - } + }, ); await User.updateMany( @@ -108,7 +108,7 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( $pull: { eventAdmin: event._id, }, - } + }, ); const updatedEvent = await Event.findOneAndUpdate( @@ -120,7 +120,7 @@ export const removeEvent: MutationResolvers["removeEvent"] = async ( }, { new: true, - } + }, ); if (updatedEvent !== null) { diff --git a/src/resolvers/Mutation/removeEventAttendee.ts b/src/resolvers/Mutation/removeEventAttendee.ts index 05e67ad2abe..2183f3e3f66 100644 --- a/src/resolvers/Mutation/removeEventAttendee.ts +++ b/src/resolvers/Mutation/removeEventAttendee.ts @@ -21,7 +21,7 @@ export const removeEventAttendee: MutationResolvers["removeEventAttendee"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -45,19 +45,19 @@ export const removeEventAttendee: MutationResolvers["removeEventAttendee"] = throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } const isUserEventAdmin = currentEvent.admins.some( - (admin) => admin.toString() === context.userId.toString() + (admin) => admin.toString() === context.userId.toString(), ); if (!isUserEventAdmin && currentUser.userType !== "SUPERADMIN") { throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -69,7 +69,7 @@ export const removeEventAttendee: MutationResolvers["removeEventAttendee"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -81,7 +81,7 @@ export const removeEventAttendee: MutationResolvers["removeEventAttendee"] = throw new errors.ConflictError( requestContext.translate(USER_NOT_REGISTERED_FOR_EVENT.MESSAGE), USER_NOT_REGISTERED_FOR_EVENT.CODE, - USER_NOT_REGISTERED_FOR_EVENT.PARAM + USER_NOT_REGISTERED_FOR_EVENT.PARAM, ); } diff --git a/src/resolvers/Mutation/removeGroupChat.ts b/src/resolvers/Mutation/removeGroupChat.ts index b2e9d6d34f8..c1ef3f31822 100644 --- a/src/resolvers/Mutation/removeGroupChat.ts +++ b/src/resolvers/Mutation/removeGroupChat.ts @@ -22,7 +22,7 @@ import { findOrganizationsInCache } from "../../services/OrganizationCache/findO export const removeGroupChat: MutationResolvers["removeGroupChat"] = async ( _parent, args, - context + context, ) => { const groupChat = await GroupChat.findOne({ _id: args.chatId, @@ -33,7 +33,7 @@ export const removeGroupChat: MutationResolvers["removeGroupChat"] = async ( throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -58,7 +58,7 @@ export const removeGroupChat: MutationResolvers["removeGroupChat"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/removeMember.ts b/src/resolvers/Mutation/removeMember.ts index 56e394af541..b24e11695ce 100644 --- a/src/resolvers/Mutation/removeMember.ts +++ b/src/resolvers/Mutation/removeMember.ts @@ -29,7 +29,7 @@ import { findOrganizationsInCache } from "../../services/OrganizationCache/findO export const removeMember: MutationResolvers["removeMember"] = async ( _parent, args, - context + context, ) => { let organization: InterfaceOrganization; @@ -52,7 +52,7 @@ export const removeMember: MutationResolvers["removeMember"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -72,19 +72,19 @@ export const removeMember: MutationResolvers["removeMember"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const userIsOrganizationMember = organization?.members.some((member) => - Types.ObjectId(member).equals(user._id) + Types.ObjectId(member).equals(user._id), ); if (!userIsOrganizationMember) { throw new errors.NotFoundError( requestContext.translate(MEMBER_NOT_FOUND_ERROR.MESSAGE), MEMBER_NOT_FOUND_ERROR.CODE, - MEMBER_NOT_FOUND_ERROR.PARAM + MEMBER_NOT_FOUND_ERROR.PARAM, ); } @@ -93,12 +93,12 @@ export const removeMember: MutationResolvers["removeMember"] = async ( throw new errors.ConflictError( requestContext.translate(USER_REMOVING_SELF.MESSAGE), USER_REMOVING_SELF.CODE, - USER_REMOVING_SELF.PARAM + USER_REMOVING_SELF.PARAM, ); } const userIsOrganizationAdmin = organization?.admins.some((admin) => - Types.ObjectId(admin).equals(user._id) + Types.ObjectId(admin).equals(user._id), ); /* @@ -109,7 +109,7 @@ export const removeMember: MutationResolvers["removeMember"] = async ( throw new errors.ConflictError( requestContext.translate(ADMIN_REMOVING_ADMIN.MESSAGE), ADMIN_REMOVING_ADMIN.CODE, - ADMIN_REMOVING_ADMIN.PARAM + ADMIN_REMOVING_ADMIN.PARAM, ); } @@ -124,7 +124,7 @@ export const removeMember: MutationResolvers["removeMember"] = async ( throw new errors.UnauthorizedError( requestContext.translate(ADMIN_REMOVING_CREATOR.MESSAGE), ADMIN_REMOVING_CREATOR.CODE, - ADMIN_REMOVING_CREATOR.PARAM + ADMIN_REMOVING_CREATOR.PARAM, ); } @@ -136,13 +136,13 @@ export const removeMember: MutationResolvers["removeMember"] = async ( { $set: { members: organization?.members.filter( - (member) => member.toString() !== user._id.toString() + (member) => member.toString() !== user._id.toString(), ), }, }, { new: true, - } + }, ).lean(); await cacheOrganizations([organization!]); @@ -156,10 +156,10 @@ export const removeMember: MutationResolvers["removeMember"] = async ( $set: { joinedOrganizations: user.joinedOrganizations.filter( (joinedOrganization) => - joinedOrganization.toString() !== organization?._id.toString() + joinedOrganization.toString() !== organization?._id.toString(), ), }, - } + }, ); return organization ?? ({} as InterfaceOrganization); diff --git a/src/resolvers/Mutation/removeOrganization.ts b/src/resolvers/Mutation/removeOrganization.ts index 5396eaaef8e..4416b416038 100644 --- a/src/resolvers/Mutation/removeOrganization.ts +++ b/src/resolvers/Mutation/removeOrganization.ts @@ -40,7 +40,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -63,7 +63,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } // Checks whether currentUser is a SUPERADMIN @@ -82,19 +82,19 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = $pull: { createdOrganizations: organization._id, }, - } + }, ); // Remove organization._id from each member's joinedOrganizations field for organization.members list. await User.updateMany( { _id: { $in: organization.members } }, - { $pull: { joinedOrganizations: organization._id } } + { $pull: { joinedOrganizations: organization._id } }, ); // Remove organization._id from each admin's joinedOrganizations field for organization.admins list. await User.updateMany( { _id: { $in: organization.admins } }, - { $pull: { joinedOrganizations: organization._id } } + { $pull: { joinedOrganizations: organization._id } }, ); /* @@ -115,7 +115,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = $pull: { membershipRequests: { $in: organization.membershipRequests }, }, - } + }, ); /* @@ -124,7 +124,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = */ await User.updateMany( { _id: { $in: organization.blockedUsers } }, - { $pull: { organizationsBlockedBy: organization._id } } + { $pull: { organizationsBlockedBy: organization._id } }, ); // Get the ids of all ActionItemCategories associated with the organization @@ -132,7 +132,7 @@ export const removeOrganization: MutationResolvers["removeOrganization"] = organizationId: organization?._id, }); const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id + (category) => category._id, ); // Remove all ActionItemCategory documents whose id is in the actionItemCategories array diff --git a/src/resolvers/Mutation/removeOrganizationCustomField.ts b/src/resolvers/Mutation/removeOrganizationCustomField.ts index 5009c2fcf62..331b3a8bb43 100644 --- a/src/resolvers/Mutation/removeOrganizationCustomField.ts +++ b/src/resolvers/Mutation/removeOrganizationCustomField.ts @@ -33,7 +33,7 @@ export const removeOrganizationCustomField: MutationResolvers["removeOrganizatio throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -45,12 +45,12 @@ export const removeOrganizationCustomField: MutationResolvers["removeOrganizatio throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(organization._id) + (organization) => organization.equals(organization._id), ); if ( @@ -59,25 +59,24 @@ export const removeOrganizationCustomField: MutationResolvers["removeOrganizatio throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } organization.customFields = organization.customFields.filter( - (field) => !field.equals(customFieldId) + (field) => !field.equals(customFieldId), ); await organization.save(); - const removedCustomField = await OrganizationCustomField.findByIdAndDelete( - customFieldId - ); + const removedCustomField = + await OrganizationCustomField.findByIdAndDelete(customFieldId); if (!removedCustomField) { throw new errors.UnauthorizedError( requestContext.translate(CUSTOM_FIELD_NOT_FOUND.MESSAGE), CUSTOM_FIELD_NOT_FOUND.CODE, - CUSTOM_FIELD_NOT_FOUND.PARAM + CUSTOM_FIELD_NOT_FOUND.PARAM, ); } diff --git a/src/resolvers/Mutation/removeOrganizationImage.ts b/src/resolvers/Mutation/removeOrganizationImage.ts index 876069d2b97..1f0849fde4a 100644 --- a/src/resolvers/Mutation/removeOrganizationImage.ts +++ b/src/resolvers/Mutation/removeOrganizationImage.ts @@ -42,7 +42,7 @@ export const removeOrganizationImage: MutationResolvers["removeOrganizationImage throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -54,7 +54,7 @@ export const removeOrganizationImage: MutationResolvers["removeOrganizationImage throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_IMAGE_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_IMAGE_NOT_FOUND_ERROR.CODE, - ORGANIZATION_IMAGE_NOT_FOUND_ERROR.PARAM + ORGANIZATION_IMAGE_NOT_FOUND_ERROR.PARAM, ); } @@ -72,7 +72,7 @@ export const removeOrganizationImage: MutationResolvers["removeOrganizationImage }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/src/resolvers/Mutation/removePost.ts b/src/resolvers/Mutation/removePost.ts index fb4077cd5f4..ea770178ec7 100644 --- a/src/resolvers/Mutation/removePost.ts +++ b/src/resolvers/Mutation/removePost.ts @@ -28,7 +28,7 @@ import { deletePreviousVideo as deleteVideo } from "../../utilities/encodedVideo export const removePost: MutationResolvers["removePost"] = async ( _parent, args, - context + context, ) => { // Get the currentUser with _id === context.userId exists. const currentUser = await User.findOne({ @@ -40,7 +40,7 @@ export const removePost: MutationResolvers["removePost"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -64,7 +64,7 @@ export const removePost: MutationResolvers["removePost"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } @@ -72,14 +72,14 @@ export const removePost: MutationResolvers["removePost"] = async ( const isCreator = post.creatorId.equals(context.userId); const isSuperAdmin = currentUser?.userType === "SUPERADMIN"; const isAdminOfPostOrganization = currentUser?.adminFor.some((orgID) => - orgID.equals(post?.organization) + orgID.equals(post?.organization), ); if (!isCreator && !isSuperAdmin && !isAdminOfPostOrganization) { throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -112,7 +112,7 @@ export const removePost: MutationResolvers["removePost"] = async ( }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/src/resolvers/Mutation/removeSampleOrganization.ts b/src/resolvers/Mutation/removeSampleOrganization.ts index e1bf9f7667f..d7683618226 100644 --- a/src/resolvers/Mutation/removeSampleOrganization.ts +++ b/src/resolvers/Mutation/removeSampleOrganization.ts @@ -18,7 +18,7 @@ export const removeSampleOrganization: MutationResolvers["removeSampleOrganizati throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -31,7 +31,7 @@ export const removeSampleOrganization: MutationResolvers["removeSampleOrganizati throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -43,7 +43,7 @@ export const removeSampleOrganization: MutationResolvers["removeSampleOrganizati throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/removeUserCustomData.ts b/src/resolvers/Mutation/removeUserCustomData.ts index c1ec2228ede..f4529bc40e3 100644 --- a/src/resolvers/Mutation/removeUserCustomData.ts +++ b/src/resolvers/Mutation/removeUserCustomData.ts @@ -21,7 +21,7 @@ export const removeUserCustomData: MutationResolvers["removeUserCustomData"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -33,12 +33,12 @@ export const removeUserCustomData: MutationResolvers["removeUserCustomData"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(organization._id) + (organization) => organization.equals(organization._id), ); if ( @@ -47,7 +47,7 @@ export const removeUserCustomData: MutationResolvers["removeUserCustomData"] = throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -60,7 +60,7 @@ export const removeUserCustomData: MutationResolvers["removeUserCustomData"] = throw new errors.NotFoundError( requestContext.translate(CUSTOM_DATA_NOT_FOUND.MESSAGE), CUSTOM_DATA_NOT_FOUND.CODE, - CUSTOM_DATA_NOT_FOUND.PARAM + CUSTOM_DATA_NOT_FOUND.PARAM, ); } diff --git a/src/resolvers/Mutation/removeUserFromGroupChat.ts b/src/resolvers/Mutation/removeUserFromGroupChat.ts index 55615e02815..db0ebe6358a 100644 --- a/src/resolvers/Mutation/removeUserFromGroupChat.ts +++ b/src/resolvers/Mutation/removeUserFromGroupChat.ts @@ -32,7 +32,7 @@ export const removeUserFromGroupChat: MutationResolvers["removeUserFromGroupChat throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -57,7 +57,7 @@ export const removeUserFromGroupChat: MutationResolvers["removeUserFromGroupChat throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -65,7 +65,7 @@ export const removeUserFromGroupChat: MutationResolvers["removeUserFromGroupChat await adminCheck(context.userId, organization); const userIsMemberOfGroupChat = groupChat.users.some((user) => - user.equals(args.userId) + user.equals(args.userId), ); // Checks if user with _id === args.userId is not a member of groupChat. @@ -73,7 +73,7 @@ export const removeUserFromGroupChat: MutationResolvers["removeUserFromGroupChat throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -85,12 +85,12 @@ export const removeUserFromGroupChat: MutationResolvers["removeUserFromGroupChat { $set: { users: groupChat.users.filter( - (user) => user.toString() !== args.userId.toString() + (user) => user.toString() !== args.userId.toString(), ), }, }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/removeUserImage.ts b/src/resolvers/Mutation/removeUserImage.ts index 0ac25515dbb..7a3fb2c7d71 100644 --- a/src/resolvers/Mutation/removeUserImage.ts +++ b/src/resolvers/Mutation/removeUserImage.ts @@ -19,7 +19,7 @@ import { deleteImage } from "../../utilities"; export const removeUserImage: MutationResolvers["removeUserImage"] = async ( _parent, _args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -30,7 +30,7 @@ export const removeUserImage: MutationResolvers["removeUserImage"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -39,7 +39,7 @@ export const removeUserImage: MutationResolvers["removeUserImage"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_PROFILE_IMAGE_NOT_FOUND_ERROR.MESSAGE), USER_PROFILE_IMAGE_NOT_FOUND_ERROR.MESSAGE, - USER_PROFILE_IMAGE_NOT_FOUND_ERROR.PARAM + USER_PROFILE_IMAGE_NOT_FOUND_ERROR.PARAM, ); } @@ -57,6 +57,6 @@ export const removeUserImage: MutationResolvers["removeUserImage"] = async ( }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/removeUserTag.ts b/src/resolvers/Mutation/removeUserTag.ts index ce0c84e5eb9..51b00ec311d 100644 --- a/src/resolvers/Mutation/removeUserTag.ts +++ b/src/resolvers/Mutation/removeUserTag.ts @@ -10,7 +10,7 @@ import { export const removeUserTag: MutationResolvers["removeUserTag"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -21,7 +21,7 @@ export const removeUserTag: MutationResolvers["removeUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -34,13 +34,13 @@ export const removeUserTag: MutationResolvers["removeUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(TAG_NOT_FOUND.MESSAGE), TAG_NOT_FOUND.CODE, - TAG_NOT_FOUND.PARAM + TAG_NOT_FOUND.PARAM, ); } // Boolean to determine whether user is an admin of organization of the tag const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(tag.organizationId) + (organization) => organization.equals(tag.organizationId), ); // Checks whether currentUser cannot delete the tag folder. @@ -51,7 +51,7 @@ export const removeUserTag: MutationResolvers["removeUserTag"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -72,7 +72,7 @@ export const removeUserTag: MutationResolvers["removeUserTag"] = async ( }, { _id: 1, - } + }, ); currentParents = currentParents .map((tag) => tag._id) diff --git a/src/resolvers/Mutation/revokeRefreshTokenForUser.ts b/src/resolvers/Mutation/revokeRefreshTokenForUser.ts index a2dadd821d6..03a5ac2efc1 100644 --- a/src/resolvers/Mutation/revokeRefreshTokenForUser.ts +++ b/src/resolvers/Mutation/revokeRefreshTokenForUser.ts @@ -14,7 +14,7 @@ export const revokeRefreshTokenForUser: MutationResolvers["revokeRefreshTokenFor }, { $unset: { token: 1 }, - } + }, ); return true; diff --git a/src/resolvers/Mutation/saveFcmToken.ts b/src/resolvers/Mutation/saveFcmToken.ts index 8988d3d603e..d49a39b8ff2 100644 --- a/src/resolvers/Mutation/saveFcmToken.ts +++ b/src/resolvers/Mutation/saveFcmToken.ts @@ -12,7 +12,7 @@ import { User } from "../../models"; export const saveFcmToken: MutationResolvers["saveFcmToken"] = async ( _parent, args, - context + context, ) => { await User.updateOne( { @@ -22,7 +22,7 @@ export const saveFcmToken: MutationResolvers["saveFcmToken"] = async ( $set: { token: args.token, }, - } + }, ); return true; diff --git a/src/resolvers/Mutation/sendMembershipRequest.ts b/src/resolvers/Mutation/sendMembershipRequest.ts index 15a4cfa99be..66c4f1fdab6 100644 --- a/src/resolvers/Mutation/sendMembershipRequest.ts +++ b/src/resolvers/Mutation/sendMembershipRequest.ts @@ -42,7 +42,7 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -55,7 +55,7 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] = throw new errors.ConflictError( requestContext.translate(MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE), MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.CODE, - MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM + MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.PARAM, ); } @@ -76,7 +76,7 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] = }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { @@ -92,7 +92,7 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] = $push: { membershipRequests: createdMembershipRequest._id, }, - } + }, ); return createdMembershipRequest.toObject(); diff --git a/src/resolvers/Mutation/sendMessageToDirectChat.ts b/src/resolvers/Mutation/sendMessageToDirectChat.ts index 097608bc0cb..cb2c0e552a9 100644 --- a/src/resolvers/Mutation/sendMessageToDirectChat.ts +++ b/src/resolvers/Mutation/sendMessageToDirectChat.ts @@ -22,7 +22,7 @@ export const sendMessageToDirectChat: MutationResolvers["sendMessageToDirectChat throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -34,13 +34,13 @@ export const sendMessageToDirectChat: MutationResolvers["sendMessageToDirectChat throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // directChat.users can only have 2 users. So, the following method works. const receiverIndex = directChat.users.findIndex( - (user) => user.toString() !== context.userId.toString() + (user) => user.toString() !== context.userId.toString(), ); const createdDirectChatMessage = await DirectChatMessage.create({ @@ -59,7 +59,7 @@ export const sendMessageToDirectChat: MutationResolvers["sendMessageToDirectChat $push: { messages: createdDirectChatMessage._id, }, - } + }, ); // calls subscription diff --git a/src/resolvers/Mutation/sendMessageToGroupChat.ts b/src/resolvers/Mutation/sendMessageToGroupChat.ts index a92b9f3e9a5..738bd0be4fb 100644 --- a/src/resolvers/Mutation/sendMessageToGroupChat.ts +++ b/src/resolvers/Mutation/sendMessageToGroupChat.ts @@ -27,7 +27,7 @@ export const sendMessageToGroupChat: MutationResolvers["sendMessageToGroupChat"] throw new errors.NotFoundError( requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } @@ -39,12 +39,12 @@ export const sendMessageToGroupChat: MutationResolvers["sendMessageToGroupChat"] throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsAMemberOfGroupChat = groupChat.users.some((user) => - user.equals(context.userId) + user.equals(context.userId), ); /* @@ -55,7 +55,7 @@ export const sendMessageToGroupChat: MutationResolvers["sendMessageToGroupChat"] throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -75,7 +75,7 @@ export const sendMessageToGroupChat: MutationResolvers["sendMessageToGroupChat"] $push: { messages: createdGroupChatMessage._id, }, - } + }, ); // calls subscription diff --git a/src/resolvers/Mutation/signUp.ts b/src/resolvers/Mutation/signUp.ts index 1ef21315661..cbed0c37952 100644 --- a/src/resolvers/Mutation/signUp.ts +++ b/src/resolvers/Mutation/signUp.ts @@ -34,7 +34,7 @@ export const signUp: MutationResolvers["signUp"] = async (_parent, args) => { throw new errors.ConflictError( requestContext.translate(EMAIL_ALREADY_EXISTS_ERROR.MESSAGE), EMAIL_ALREADY_EXISTS_ERROR.CODE, - EMAIL_ALREADY_EXISTS_ERROR.PARAM + EMAIL_ALREADY_EXISTS_ERROR.PARAM, ); } @@ -59,7 +59,7 @@ export const signUp: MutationResolvers["signUp"] = async (_parent, args) => { throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } } diff --git a/src/resolvers/Mutation/togglePostPin.ts b/src/resolvers/Mutation/togglePostPin.ts index ebd55e4ee5f..d79724cc438 100644 --- a/src/resolvers/Mutation/togglePostPin.ts +++ b/src/resolvers/Mutation/togglePostPin.ts @@ -19,7 +19,7 @@ import { isValidString } from "../../libraries/validators/validateString"; export const togglePostPin: MutationResolvers["togglePostPin"] = async ( _parent, args, - context + context, ) => { // Get the current user const currentUser = await User.findOne({ @@ -31,7 +31,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -55,13 +55,13 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } // Check if the current user is authorized to perform the operation const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organizationId) => organizationId.equals(post?.organization) + (organizationId) => organizationId.equals(post?.organization), ); if ( @@ -71,7 +71,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_TO_PIN.MESSAGE), USER_NOT_AUTHORIZED_TO_PIN.CODE, - USER_NOT_AUTHORIZED_TO_PIN.PARAM + USER_NOT_AUTHORIZED_TO_PIN.PARAM, ); } @@ -92,7 +92,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( await cacheOrganizations([organization!]); } const currentPostIsPinned = organization?.pinnedPosts.some((postID) => - Types.ObjectId(postID).equals(args.id) + Types.ObjectId(postID).equals(args.id), ); if (currentPostIsPinned) { @@ -107,7 +107,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -123,7 +123,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( pinned: false, title: "", }, - } + }, ).lean(); if (updatedPost !== null) { @@ -135,7 +135,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( if (!args.title) { throw new errors.InputValidationError( requestContext.translate(PLEASE_PROVIDE_TITLE.MESSAGE), - PLEASE_PROVIDE_TITLE.CODE + PLEASE_PROVIDE_TITLE.CODE, ); } @@ -144,9 +144,9 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( if (!validationResultTitle.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } } @@ -162,7 +162,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -177,7 +177,7 @@ export const togglePostPin: MutationResolvers["togglePostPin"] = async ( pinned: true, title: args?.title, }, - } + }, ).lean(); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/unassignUserTag.ts b/src/resolvers/Mutation/unassignUserTag.ts index b1fe4b18972..f35a4d0f042 100644 --- a/src/resolvers/Mutation/unassignUserTag.ts +++ b/src/resolvers/Mutation/unassignUserTag.ts @@ -11,7 +11,7 @@ import { export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -22,7 +22,7 @@ export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -35,13 +35,13 @@ export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(TAG_NOT_FOUND.MESSAGE), TAG_NOT_FOUND.CODE, - TAG_NOT_FOUND.PARAM + TAG_NOT_FOUND.PARAM, ); } // Boolean to determine whether user is an admin of organization of the tag. const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(tag?.organizationId) + (organization) => organization.equals(tag?.organizationId), ); // Checks whether currentUser can assign the tag or not. @@ -52,7 +52,7 @@ export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -65,7 +65,7 @@ export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -78,7 +78,7 @@ export const unassignUserTag: MutationResolvers["unassignUserTag"] = async ( throw new errors.ConflictError( requestContext.translate(USER_DOES_NOT_HAVE_THE_TAG.MESSAGE), USER_DOES_NOT_HAVE_THE_TAG.CODE, - USER_DOES_NOT_HAVE_THE_TAG.PARAM + USER_DOES_NOT_HAVE_THE_TAG.PARAM, ); } diff --git a/src/resolvers/Mutation/unblockUser.ts b/src/resolvers/Mutation/unblockUser.ts index 7b7087e0531..6b42ee9a7ec 100644 --- a/src/resolvers/Mutation/unblockUser.ts +++ b/src/resolvers/Mutation/unblockUser.ts @@ -25,7 +25,7 @@ import { Types } from "mongoose"; export const unblockUser: MutationResolvers["unblockUser"] = async ( _parent, args, - context + context, ) => { let organization: InterfaceOrganization; @@ -48,7 +48,7 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -61,7 +61,7 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -69,7 +69,7 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( await adminCheck(context.userId, organization); const userIsBlockedFromOrganization = organization.blockedUsers.some( - (blockedUser) => Types.ObjectId(blockedUser).equals(user._id) + (blockedUser) => Types.ObjectId(blockedUser).equals(user._id), ); // checks if user with _id === args.userId is blocked by organzation with _id == args.organizationId @@ -77,7 +77,7 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -89,13 +89,13 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( { $set: { blockedUsers: organization.blockedUsers.filter( - (blockedUser) => !user._id.equals(blockedUser) + (blockedUser) => !user._id.equals(blockedUser), ), }, }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { @@ -111,14 +111,14 @@ export const unblockUser: MutationResolvers["unblockUser"] = async ( organizationsBlockedBy: user.organizationsBlockedBy.filter( (organizationBlockedBy) => !Types.ObjectId(String(organization._id)).equals( - organizationBlockedBy - ) + organizationBlockedBy, + ), ), }, }, { new: true, - } + }, ) .select(["-password"]) .lean(); diff --git a/src/resolvers/Mutation/unlikeComment.ts b/src/resolvers/Mutation/unlikeComment.ts index b26fb18167e..32e2adddb40 100644 --- a/src/resolvers/Mutation/unlikeComment.ts +++ b/src/resolvers/Mutation/unlikeComment.ts @@ -17,7 +17,7 @@ import { cacheComments } from "../../services/CommentCache/cacheComments"; export const unlikeComment: MutationResolvers["unlikeComment"] = async ( _parent, args, - context + context, ) => { let comment; @@ -39,12 +39,12 @@ export const unlikeComment: MutationResolvers["unlikeComment"] = async ( throw new errors.NotFoundError( requestContext.translate(COMMENT_NOT_FOUND_ERROR.MESSAGE), COMMENT_NOT_FOUND_ERROR.CODE, - COMMENT_NOT_FOUND_ERROR.PARAM + COMMENT_NOT_FOUND_ERROR.PARAM, ); } const currentUserHasLikedComment = comment.likedBy.some((liker) => - liker.equals(context.userId) + liker.equals(context.userId), ); if (currentUserHasLikedComment === true) { @@ -62,7 +62,7 @@ export const unlikeComment: MutationResolvers["unlikeComment"] = async ( }, { new: true, - } + }, ).lean(); if (updatedComment !== null) { diff --git a/src/resolvers/Mutation/unlikePost.ts b/src/resolvers/Mutation/unlikePost.ts index 2f36334b7a4..605c2bdf770 100644 --- a/src/resolvers/Mutation/unlikePost.ts +++ b/src/resolvers/Mutation/unlikePost.ts @@ -18,7 +18,7 @@ import { cachePosts } from "../../services/PostCache/cachePosts"; export const unlikePost: MutationResolvers["unlikePost"] = async ( _parent, args, - context + context, ) => { let post: InterfacePost | null; @@ -39,12 +39,12 @@ export const unlikePost: MutationResolvers["unlikePost"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } const currentUserHasLikedPost = post.likedBy.some((liker) => - liker.equals(context.userId) + liker.equals(context.userId), ); if (currentUserHasLikedPost === true) { @@ -62,7 +62,7 @@ export const unlikePost: MutationResolvers["unlikePost"] = async ( }, { new: true, - } + }, ).lean(); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/unregisterForEventByUser.ts b/src/resolvers/Mutation/unregisterForEventByUser.ts index a7ef40cce13..246d6b60862 100644 --- a/src/resolvers/Mutation/unregisterForEventByUser.ts +++ b/src/resolvers/Mutation/unregisterForEventByUser.ts @@ -43,7 +43,7 @@ export const unregisterForEventByUser: MutationResolvers["unregisterForEventByUs throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } @@ -56,7 +56,7 @@ export const unregisterForEventByUser: MutationResolvers["unregisterForEventByUs throw new errors.NotFoundError( requestContext.translate(USER_ALREADY_UNREGISTERED_ERROR.MESSAGE), USER_ALREADY_UNREGISTERED_ERROR.CODE, - USER_ALREADY_UNREGISTERED_ERROR.PARAM + USER_ALREADY_UNREGISTERED_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/updateActionItem.ts b/src/resolvers/Mutation/updateActionItem.ts index 7a17387f2b5..0257d7da40d 100644 --- a/src/resolvers/Mutation/updateActionItem.ts +++ b/src/resolvers/Mutation/updateActionItem.ts @@ -38,7 +38,7 @@ type UpdateActionItemInputType = { export const updateActionItem: MutationResolvers["updateActionItem"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -49,7 +49,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -64,7 +64,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(ACTION_ITEM_NOT_FOUND_ERROR.MESSAGE), ACTION_ITEM_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_NOT_FOUND_ERROR.PARAM, ); } @@ -72,7 +72,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( if (args.data.assigneeId) { sameAssignedUser = Types.ObjectId(actionItem.assigneeId).equals( - args.data.assigneeId + args.data.assigneeId, ); if (!sameAssignedUser) { @@ -85,7 +85,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -94,7 +94,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( userIsOrganizationMember = newAssignedUser.joinedOrganizations.some( (organizationId) => organizationId === currorganizationId || - Types.ObjectId(organizationId).equals(currorganizationId) + Types.ObjectId(organizationId).equals(currorganizationId), ); // Checks if the new asignee is a member of the organization @@ -102,7 +102,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_MEMBER_FOR_ORGANIZATION.MESSAGE), USER_NOT_MEMBER_FOR_ORGANIZATION.CODE, - USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM + USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM, ); } } @@ -112,8 +112,8 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( (ogranizationId) => ogranizationId === actionItem.actionItemCategoryId.organizationId || Types.ObjectId(ogranizationId).equals( - actionItem.actionItemCategoryId.organizationId - ) + actionItem.actionItemCategoryId.organizationId, + ), ); let currentUserIsEventAdmin = false; @@ -140,14 +140,15 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } // Checks if the currUser is an admin of the event currentUserIsEventAdmin = currEvent.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || + Types.ObjectId(admin).equals(context.userId), ); } @@ -160,7 +161,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -183,7 +184,7 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async ( }, { new: true, - } + }, ).lean(); return updatedActionItem; diff --git a/src/resolvers/Mutation/updateActionItemCategory.ts b/src/resolvers/Mutation/updateActionItemCategory.ts index d2deaf31f86..7be02223c64 100644 --- a/src/resolvers/Mutation/updateActionItemCategory.ts +++ b/src/resolvers/Mutation/updateActionItemCategory.ts @@ -34,7 +34,7 @@ export const updateActionItemCategory: MutationResolvers["updateActionItemCatego throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -49,7 +49,7 @@ export const updateActionItemCategory: MutationResolvers["updateActionItemCatego throw new errors.NotFoundError( requestContext.translate(ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE), ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM, ); } @@ -64,7 +64,7 @@ export const updateActionItemCategory: MutationResolvers["updateActionItemCatego }, { new: true, - } + }, ).lean(); return updatedCategory; diff --git a/src/resolvers/Mutation/updateAdvertisement.ts b/src/resolvers/Mutation/updateAdvertisement.ts index 5a98ceb2f2e..3960ab6a51a 100644 --- a/src/resolvers/Mutation/updateAdvertisement.ts +++ b/src/resolvers/Mutation/updateAdvertisement.ts @@ -20,7 +20,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.InputValidationError( requestContext.translate(INPUT_NOT_FOUND_ERROR.MESSAGE), INPUT_NOT_FOUND_ERROR.CODE, - INPUT_NOT_FOUND_ERROR.PARAM + INPUT_NOT_FOUND_ERROR.PARAM, ); } @@ -34,7 +34,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.InputValidationError( requestContext.translate(FIELD_NON_EMPTY_ERROR.MESSAGE), FIELD_NON_EMPTY_ERROR.CODE, - FIELD_NON_EMPTY_ERROR.PARAM + FIELD_NON_EMPTY_ERROR.PARAM, ); } } @@ -47,7 +47,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -55,7 +55,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -69,7 +69,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.InputValidationError( requestContext.translate(START_DATE_VALIDATION_ERROR.MESSAGE), START_DATE_VALIDATION_ERROR.CODE, - START_DATE_VALIDATION_ERROR.PARAM + START_DATE_VALIDATION_ERROR.PARAM, ); } @@ -78,7 +78,7 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = throw new errors.InputValidationError( requestContext.translate(END_DATE_VALIDATION_ERROR.MESSAGE), END_DATE_VALIDATION_ERROR.CODE, - END_DATE_VALIDATION_ERROR.PARAM + END_DATE_VALIDATION_ERROR.PARAM, ); } @@ -91,14 +91,14 @@ export const updateAdvertisement: MutationResolvers["updateAdvertisement"] = }, { new: true, - } + }, ).lean(); if (!updatedAdvertisement) { throw new errors.NotFoundError( requestContext.translate(ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE), ADVERTISEMENT_NOT_FOUND_ERROR.CODE, - ADVERTISEMENT_NOT_FOUND_ERROR.PARAM + ADVERTISEMENT_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Mutation/updateEvent.ts b/src/resolvers/Mutation/updateEvent.ts index a33a38a7406..1e0ab35a0e1 100644 --- a/src/resolvers/Mutation/updateEvent.ts +++ b/src/resolvers/Mutation/updateEvent.ts @@ -26,7 +26,7 @@ import { Types } from "mongoose"; export const updateEvent: MutationResolvers["updateEvent"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -37,7 +37,7 @@ export const updateEvent: MutationResolvers["updateEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -62,13 +62,13 @@ export const updateEvent: MutationResolvers["updateEvent"] = async ( throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } const currentUserIsEventAdmin = event.admins.some( (admin) => - admin === context.userID || Types.ObjectId(admin).equals(context.userId) + admin === context.userID || Types.ObjectId(admin).equals(context.userId), ); // checks if current user is an admin of the event with _id === args.id @@ -79,7 +79,7 @@ export const updateEvent: MutationResolvers["updateEvent"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -87,31 +87,31 @@ export const updateEvent: MutationResolvers["updateEvent"] = async ( const validationResultTitle = isValidString(args.data?.title ?? "", 256); const validationResultDescription = isValidString( args.data?.description ?? "", - 500 + 500, ); const validationResultLocation = isValidString(args.data?.location ?? "", 50); if (!validationResultTitle.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultDescription.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultLocation.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } @@ -124,7 +124,7 @@ export const updateEvent: MutationResolvers["updateEvent"] = async ( }, { new: true, - } + }, ).lean(); if (updatedEvent !== null) { diff --git a/src/resolvers/Mutation/updateLanguage.ts b/src/resolvers/Mutation/updateLanguage.ts index 45e07508b01..3f7929c6cda 100644 --- a/src/resolvers/Mutation/updateLanguage.ts +++ b/src/resolvers/Mutation/updateLanguage.ts @@ -12,7 +12,7 @@ import { User } from "../../models"; export const updateLanguage: MutationResolvers["updateLanguage"] = async ( _parent, args, - context + context, ) => { return await User.findOneAndUpdate( { @@ -25,6 +25,6 @@ export const updateLanguage: MutationResolvers["updateLanguage"] = async ( }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/updateOrganization.ts b/src/resolvers/Mutation/updateOrganization.ts index 996d0505743..ce313dc6efc 100644 --- a/src/resolvers/Mutation/updateOrganization.ts +++ b/src/resolvers/Mutation/updateOrganization.ts @@ -39,7 +39,7 @@ export const updateOrganization: MutationResolvers["updateOrganization"] = throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -50,7 +50,7 @@ export const updateOrganization: MutationResolvers["updateOrganization"] = if (args.file) { uploadImageFileName = await uploadEncodedImage( args.file, - organization?.image + organization?.image, ); } @@ -66,7 +66,7 @@ export const updateOrganization: MutationResolvers["updateOrganization"] = }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/src/resolvers/Mutation/updatePluginStatus.ts b/src/resolvers/Mutation/updatePluginStatus.ts index b819062d300..a3dd77bbb21 100644 --- a/src/resolvers/Mutation/updatePluginStatus.ts +++ b/src/resolvers/Mutation/updatePluginStatus.ts @@ -25,7 +25,7 @@ export const updatePluginStatus: MutationResolvers["updatePluginStatus"] = throw new errors.NotFoundError( requestContext.translate(PLUGIN_NOT_FOUND.MESSAGE), PLUGIN_NOT_FOUND.CODE, - PLUGIN_NOT_FOUND.PARAM + PLUGIN_NOT_FOUND.PARAM, ); } @@ -34,7 +34,7 @@ export const updatePluginStatus: MutationResolvers["updatePluginStatus"] = if (uninstalledOrgsList.includes(currOrgID)) { //if already uninstalled then install it by removing from array uninstalledOrgsList = uninstalledOrgsList.filter( - (oid: any) => oid != currOrgID + (oid: any) => oid != currOrgID, ); } else { //not already present then uninstall plugin on that org by adding it to the list @@ -51,7 +51,7 @@ export const updatePluginStatus: MutationResolvers["updatePluginStatus"] = }, { new: true, - } + }, ).lean(); // calls subscription diff --git a/src/resolvers/Mutation/updatePost.ts b/src/resolvers/Mutation/updatePost.ts index 6b358993efa..517025341ed 100644 --- a/src/resolvers/Mutation/updatePost.ts +++ b/src/resolvers/Mutation/updatePost.ts @@ -18,7 +18,7 @@ import { uploadEncodedVideo } from "../../utilities/encodedVideoStorage/uploadEn export const updatePost: MutationResolvers["updatePost"] = async ( _parent, args, - context + context, ) => { let post: InterfacePost | null; @@ -40,7 +40,7 @@ export const updatePost: MutationResolvers["updatePost"] = async ( throw new errors.NotFoundError( requestContext.translate(POST_NOT_FOUND_ERROR.MESSAGE), POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } @@ -51,21 +51,21 @@ export const updatePost: MutationResolvers["updatePost"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } if (args.data?.imageUrl && args.data?.imageUrl !== null) { args.data.imageUrl = await uploadEncodedImage( args.data.imageUrl, - post.imageUrl + post.imageUrl, ); } if (args.data?.videoUrl && args.data?.videoUrl !== null) { args.data.videoUrl = await uploadEncodedVideo( args.data.videoUrl, - post.videoUrl + post.videoUrl, ); } @@ -73,12 +73,12 @@ export const updatePost: MutationResolvers["updatePost"] = async ( if (args.data?.title && !post.pinned) { throw new errors.InputValidationError( requestContext.translate(POST_NEEDS_TO_BE_PINNED.MESSAGE), - POST_NEEDS_TO_BE_PINNED.CODE + POST_NEEDS_TO_BE_PINNED.CODE, ); } else if (!args.data?.title && post.pinned) { throw new errors.InputValidationError( requestContext.translate(PLEASE_PROVIDE_TITLE.MESSAGE), - PLEASE_PROVIDE_TITLE.CODE + PLEASE_PROVIDE_TITLE.CODE, ); } @@ -88,17 +88,17 @@ export const updatePost: MutationResolvers["updatePost"] = async ( if (!validationResultTitle.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } if (!validationResultText.isLessThanMaxLength) { throw new errors.InputValidationError( requestContext.translate( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information`, ), - LENGTH_VALIDATION_ERROR.CODE + LENGTH_VALIDATION_ERROR.CODE, ); } @@ -111,7 +111,7 @@ export const updatePost: MutationResolvers["updatePost"] = async ( }, { new: true, - } + }, ).lean(); if (updatedPost !== null) { diff --git a/src/resolvers/Mutation/updateUserPassword.ts b/src/resolvers/Mutation/updateUserPassword.ts index ff20e208c4c..3123451a9d3 100644 --- a/src/resolvers/Mutation/updateUserPassword.ts +++ b/src/resolvers/Mutation/updateUserPassword.ts @@ -17,13 +17,13 @@ export const updateUserPassword: MutationResolvers["updateUserPassword"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } const isPasswordValid = await bcrypt.compare( args.data.previousPassword, - currentUser.password + currentUser.password, ); // Checks whether password is invalid. @@ -32,13 +32,13 @@ export const updateUserPassword: MutationResolvers["updateUserPassword"] = [ { message: requestContext.translate( - INVALID_CREDENTIALS_ERROR.MESSAGE + INVALID_CREDENTIALS_ERROR.MESSAGE, ), code: INVALID_CREDENTIALS_ERROR.CODE, param: INVALID_CREDENTIALS_ERROR.PARAM, }, ], - requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE) + requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE), ); } @@ -47,13 +47,13 @@ export const updateUserPassword: MutationResolvers["updateUserPassword"] = [ { message: requestContext.translate( - INVALID_CREDENTIALS_ERROR.MESSAGE + INVALID_CREDENTIALS_ERROR.MESSAGE, ), code: INVALID_CREDENTIALS_ERROR.CODE, param: INVALID_CREDENTIALS_ERROR.PARAM, }, ], - requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE) + requestContext.translate(INVALID_CREDENTIALS_ERROR.MESSAGE), ); } @@ -71,6 +71,6 @@ export const updateUserPassword: MutationResolvers["updateUserPassword"] = }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/updateUserProfile.ts b/src/resolvers/Mutation/updateUserProfile.ts index d63d6821a54..d6844af8675 100644 --- a/src/resolvers/Mutation/updateUserProfile.ts +++ b/src/resolvers/Mutation/updateUserProfile.ts @@ -19,7 +19,7 @@ import { uploadEncodedImage } from "../../utilities/encodedImageStorage/uploadEn export const updateUserProfile: MutationResolvers["updateUserProfile"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -29,7 +29,7 @@ export const updateUserProfile: MutationResolvers["updateUserProfile"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -42,7 +42,7 @@ export const updateUserProfile: MutationResolvers["updateUserProfile"] = async ( throw new errors.ConflictError( requestContext.translate(EMAIL_ALREADY_EXISTS_ERROR.MESSAGE), EMAIL_ALREADY_EXISTS_ERROR.MESSAGE, - EMAIL_ALREADY_EXISTS_ERROR.PARAM + EMAIL_ALREADY_EXISTS_ERROR.PARAM, ); } } @@ -52,7 +52,7 @@ export const updateUserProfile: MutationResolvers["updateUserProfile"] = async ( if (args.file) { uploadImageFileName = await uploadEncodedImage( args.file, - currentUser?.image + currentUser?.image, ); } @@ -126,7 +126,7 @@ export const updateUserProfile: MutationResolvers["updateUserProfile"] = async ( { new: true, runValidators: true, - } + }, ).lean(); updatedUser!.image = updatedUser?.image ? `${context.apiRootUrl}${updatedUser?.image}` diff --git a/src/resolvers/Mutation/updateUserRoleInOrganization.ts b/src/resolvers/Mutation/updateUserRoleInOrganization.ts index 44ab448d769..c314d7e345f 100644 --- a/src/resolvers/Mutation/updateUserRoleInOrganization.ts +++ b/src/resolvers/Mutation/updateUserRoleInOrganization.ts @@ -31,7 +31,7 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } @@ -42,20 +42,20 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // Checks whether user to be removed is a member of the organization. const userIsOrganizationMember = organization?.members.some((member) => - Types.ObjectId(member).equals(user._id) + Types.ObjectId(member).equals(user._id), ); if (!userIsOrganizationMember) { throw new errors.NotFoundError( requestContext.translate(USER_NOT_MEMBER_FOR_ORGANIZATION.MESSAGE), USER_NOT_MEMBER_FOR_ORGANIZATION.CODE, - USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM + USER_NOT_MEMBER_FOR_ORGANIZATION.PARAM, ); } @@ -65,13 +65,13 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } // Check whether loggedIn user is admin of the organization. const loggedInUserIsOrganizationAdmin = organization?.admins.some((admin) => - Types.ObjectId(admin).equals(loggedInUser._id) + Types.ObjectId(admin).equals(loggedInUser._id), ); if ( @@ -81,7 +81,7 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.NotFoundError( requestContext.translate(USER_NOT_AUTHORIZED_ADMIN.MESSAGE), USER_NOT_AUTHORIZED_ADMIN.CODE, - USER_NOT_AUTHORIZED_ADMIN.PARAM + USER_NOT_AUTHORIZED_ADMIN.PARAM, ); } // Admin of Org cannot change the role of SUPERADMIN in an organization. @@ -93,7 +93,7 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.NotFoundError( requestContext.translate(USER_NOT_AUTHORIZED_ADMIN.MESSAGE), USER_NOT_AUTHORIZED_ADMIN.CODE, - USER_NOT_AUTHORIZED_ADMIN.PARAM + USER_NOT_AUTHORIZED_ADMIN.PARAM, ); } // ADMIN cannot change the role of itself @@ -104,7 +104,7 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.ConflictError( requestContext.translate(ADMIN_CANNOT_CHANGE_ITS_ROLE.MESSAGE), ADMIN_CANNOT_CHANGE_ITS_ROLE.CODE, - ADMIN_CANNOT_CHANGE_ITS_ROLE.PARAM + ADMIN_CANNOT_CHANGE_ITS_ROLE.PARAM, ); } @@ -113,7 +113,7 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr throw new errors.UnauthorizedError( requestContext.translate(ADMIN_CHANGING_ROLE_OF_CREATOR.MESSAGE), ADMIN_CHANGING_ROLE_OF_CREATOR.CODE, - ADMIN_CHANGING_ROLE_OF_CREATOR.PARAM + ADMIN_CHANGING_ROLE_OF_CREATOR.PARAM, ); } @@ -123,11 +123,11 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr { _id: args.organizationId }, { $push: { admins: args.userId }, - } + }, ); await User.updateOne( { _id: args.userId }, - { $push: { adminFor: args.organizationId } } + { $push: { adminFor: args.organizationId } }, ); return { ...organization, ...updatedOrg }; } else { @@ -135,11 +135,11 @@ export const updateUserRoleInOrganization: MutationResolvers["updateUserRoleInOr { _id: args.organizationId }, { $pull: { admins: args.userId }, - } + }, ).lean(); await User.updateOne( { _id: args.userId }, - { $pull: { adminFor: args.organizationId } } + { $pull: { adminFor: args.organizationId } }, ); return { ...organization, ...updatedOrg }; } diff --git a/src/resolvers/Mutation/updateUserTag.ts b/src/resolvers/Mutation/updateUserTag.ts index 89269b79c6d..7badda1ca76 100644 --- a/src/resolvers/Mutation/updateUserTag.ts +++ b/src/resolvers/Mutation/updateUserTag.ts @@ -12,7 +12,7 @@ import { export const updateUserTag: MutationResolvers["updateUserTag"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -23,7 +23,7 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -36,13 +36,13 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( throw new errors.NotFoundError( requestContext.translate(TAG_NOT_FOUND.MESSAGE), TAG_NOT_FOUND.CODE, - TAG_NOT_FOUND.PARAM + TAG_NOT_FOUND.PARAM, ); } // Boolean to determine whether user is an admin of organization of the tag folder. const currentUserIsOrganizationAdmin = currentUser.adminFor.some( - (organization) => organization.equals(existingTag?.organizationId) + (organization) => organization.equals(existingTag?.organizationId), ); // Checks whether currentUser can update the tag @@ -53,7 +53,7 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM + USER_NOT_AUTHORIZED_ERROR.PARAM, ); } @@ -62,7 +62,7 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( throw new errors.ConflictError( requestContext.translate(NO_CHANGE_IN_TAG_NAME.MESSAGE), NO_CHANGE_IN_TAG_NAME.CODE, - NO_CHANGE_IN_TAG_NAME.PARAM + NO_CHANGE_IN_TAG_NAME.PARAM, ); } @@ -77,7 +77,7 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( throw new errors.ConflictError( requestContext.translate(TAG_ALREADY_EXISTS.MESSAGE), TAG_ALREADY_EXISTS.CODE, - TAG_ALREADY_EXISTS.PARAM + TAG_ALREADY_EXISTS.PARAM, ); } @@ -91,6 +91,6 @@ export const updateUserTag: MutationResolvers["updateUserTag"] = async ( }, { new: true, - } + }, ).lean(); }; diff --git a/src/resolvers/Mutation/updateUserType.ts b/src/resolvers/Mutation/updateUserType.ts index 63359df9122..ffd75fa19c4 100644 --- a/src/resolvers/Mutation/updateUserType.ts +++ b/src/resolvers/Mutation/updateUserType.ts @@ -18,7 +18,7 @@ import { superAdminCheck } from "../../utilities"; export const updateUserType: MutationResolvers["updateUserType"] = async ( _parent, args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -30,7 +30,7 @@ export const updateUserType: MutationResolvers["updateUserType"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -39,7 +39,7 @@ export const updateUserType: MutationResolvers["updateUserType"] = async ( throw new errors.InputValidationError( requestContext.translate(SUPERADMIN_CANT_CHANGE_OWN_ROLE.MESSAGE), SUPERADMIN_CANT_CHANGE_OWN_ROLE.CODE, - SUPERADMIN_CANT_CHANGE_OWN_ROLE.PARAM + SUPERADMIN_CANT_CHANGE_OWN_ROLE.PARAM, ); } @@ -51,7 +51,7 @@ export const updateUserType: MutationResolvers["updateUserType"] = async ( throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -62,7 +62,7 @@ export const updateUserType: MutationResolvers["updateUserType"] = async ( { userType: args.data.userType!, adminApproved: true, - } + }, ); return true; diff --git a/src/resolvers/Organization/blockedUsers.ts b/src/resolvers/Organization/blockedUsers.ts index d22642f3a38..70b5a5f9b59 100644 --- a/src/resolvers/Organization/blockedUsers.ts +++ b/src/resolvers/Organization/blockedUsers.ts @@ -6,7 +6,7 @@ import type { OrganizationResolvers } from "../../types/generatedGraphQLTypes"; * @returns An object that contains the list of blocked users for the organization. */ export const blockedUsers: OrganizationResolvers["blockedUsers"] = async ( - parent + parent, ) => { return await User.find({ _id: { diff --git a/src/resolvers/Organization/creator.ts b/src/resolvers/Organization/creator.ts index 180f32d6e45..822d0f6ad84 100644 --- a/src/resolvers/Organization/creator.ts +++ b/src/resolvers/Organization/creator.ts @@ -16,7 +16,7 @@ export const creator: OrganizationResolvers["creator"] = async (parent) => { throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Organization/image.ts b/src/resolvers/Organization/image.ts index a6b5ce25226..c81fedcf606 100644 --- a/src/resolvers/Organization/image.ts +++ b/src/resolvers/Organization/image.ts @@ -4,7 +4,7 @@ import type { OrganizationResolvers } from "../../types/generatedGraphQLTypes"; export const image: OrganizationResolvers["image"] = ( parent, _args, - context + context, ) => { if (parent.image) { return `${context.apiRootUrl}${parent.image}`; diff --git a/src/resolvers/Organization/pinnedPosts.ts b/src/resolvers/Organization/pinnedPosts.ts index a26548f2fdc..e2347ae6ff4 100644 --- a/src/resolvers/Organization/pinnedPosts.ts +++ b/src/resolvers/Organization/pinnedPosts.ts @@ -4,7 +4,7 @@ import { findPostsInCache } from "../../services/PostCache/findPostsInCache"; import type { OrganizationResolvers } from "../../types/generatedGraphQLTypes"; export const pinnedPosts: OrganizationResolvers["pinnedPosts"] = async ( - parent + parent, ) => { const postsInCache = await findPostsInCache(parent.pinnedPosts); diff --git a/src/resolvers/Query/actionItem.ts b/src/resolvers/Query/actionItem.ts index 6d8e2cbfa27..ac4d5d1d6ca 100644 --- a/src/resolvers/Query/actionItem.ts +++ b/src/resolvers/Query/actionItem.ts @@ -12,7 +12,7 @@ import { ACTION_ITEM_NOT_FOUND_ERROR } from "../../constants"; */ export const actionItem: QueryResolvers["actionItem"] = async ( _parent, - args + args, ) => { const actionItem = await ActionItem.findOne({ _id: args.id, @@ -22,7 +22,7 @@ export const actionItem: QueryResolvers["actionItem"] = async ( throw new errors.NotFoundError( ACTION_ITEM_NOT_FOUND_ERROR.DESC, ACTION_ITEM_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/actionItemCategory.ts b/src/resolvers/Query/actionItemCategory.ts index e0cfb1232e7..508d67ec159 100644 --- a/src/resolvers/Query/actionItemCategory.ts +++ b/src/resolvers/Query/actionItemCategory.ts @@ -12,7 +12,7 @@ import { ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR } from "../../constants"; */ export const actionItemCategory: QueryResolvers["actionItemCategory"] = async ( _parent, - args + args, ) => { const actionItemCategory = await ActionItemCategory.findOne({ _id: args.id, @@ -22,7 +22,7 @@ export const actionItemCategory: QueryResolvers["actionItemCategory"] = async ( throw new errors.NotFoundError( ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.DESC, ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.CODE, - ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM + ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/actionItemsByEvent.ts b/src/resolvers/Query/actionItemsByEvent.ts index d031dfdb782..08944db8b2b 100644 --- a/src/resolvers/Query/actionItemsByEvent.ts +++ b/src/resolvers/Query/actionItemsByEvent.ts @@ -8,7 +8,7 @@ import { ActionItem } from "../../models"; */ export const actionItemsByEvent: QueryResolvers["actionItemsByEvent"] = async ( _parent, - args + args, ) => { const actionItems = await ActionItem.find({ eventId: args.eventId, diff --git a/src/resolvers/Query/actionItemsByOrganization.ts b/src/resolvers/Query/actionItemsByOrganization.ts index 4520f02af6b..6513641b5a9 100644 --- a/src/resolvers/Query/actionItemsByOrganization.ts +++ b/src/resolvers/Query/actionItemsByOrganization.ts @@ -13,7 +13,7 @@ export const actionItemsByOrganization: QueryResolvers["actionItemsByOrganizatio organizationId: args.organizationId, }); const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id + (category) => category._id, ); const actionItems = await ActionItem.find({ diff --git a/src/resolvers/Query/checkAuth.ts b/src/resolvers/Query/checkAuth.ts index 93daebe0cc1..9709cd771d0 100644 --- a/src/resolvers/Query/checkAuth.ts +++ b/src/resolvers/Query/checkAuth.ts @@ -13,7 +13,7 @@ import { errors } from "../../libraries"; export const checkAuth: QueryResolvers["checkAuth"] = async ( _parent, _args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -23,7 +23,7 @@ export const checkAuth: QueryResolvers["checkAuth"] = async ( throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.DESC, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/customFieldsByOrganization.ts b/src/resolvers/Query/customFieldsByOrganization.ts index 93094d1682d..0332a100f2e 100644 --- a/src/resolvers/Query/customFieldsByOrganization.ts +++ b/src/resolvers/Query/customFieldsByOrganization.ts @@ -22,7 +22,7 @@ export const customFieldsByOrganization: QueryResolvers["customFieldsByOrganizat throw new errors.NotFoundError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/directChatsByUserID.ts b/src/resolvers/Query/directChatsByUserID.ts index 8ea9dafbf69..efb34e93dd7 100644 --- a/src/resolvers/Query/directChatsByUserID.ts +++ b/src/resolvers/Query/directChatsByUserID.ts @@ -20,7 +20,7 @@ export const directChatsByUserID: QueryResolvers["directChatsByUserID"] = throw new errors.NotFoundError( "DirectChats not found", "directChats.notFound", - "directChats" + "directChats", ); } diff --git a/src/resolvers/Query/directChatsMessagesByChatID.ts b/src/resolvers/Query/directChatsMessagesByChatID.ts index 5df598c6d96..173eada6e5a 100644 --- a/src/resolvers/Query/directChatsMessagesByChatID.ts +++ b/src/resolvers/Query/directChatsMessagesByChatID.ts @@ -23,7 +23,7 @@ export const directChatsMessagesByChatID: QueryResolvers["directChatsMessagesByC throw new errors.NotFoundError( CHAT_NOT_FOUND_ERROR.DESC, CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM + CHAT_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/event.ts b/src/resolvers/Query/event.ts index 2dd49a73c99..a905b90986b 100644 --- a/src/resolvers/Query/event.ts +++ b/src/resolvers/Query/event.ts @@ -23,7 +23,7 @@ export const event: QueryResolvers["event"] = async (_parent, args) => { throw new errors.NotFoundError( EVENT_NOT_FOUND_ERROR.DESC, EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/getDonationById.ts b/src/resolvers/Query/getDonationById.ts index 8b21b4a7f0e..09a7ee0149a 100644 --- a/src/resolvers/Query/getDonationById.ts +++ b/src/resolvers/Query/getDonationById.ts @@ -10,7 +10,7 @@ import { Donation } from "../../models"; */ export const getDonationById: QueryResolvers["getDonationById"] = async ( _parent, - args + args, ) => { const donation = await Donation.findOne({ _id: args.id, diff --git a/src/resolvers/Query/getDonationByOrgId.ts b/src/resolvers/Query/getDonationByOrgId.ts index a766ec65b5c..2dfe0cfe74a 100644 --- a/src/resolvers/Query/getDonationByOrgId.ts +++ b/src/resolvers/Query/getDonationByOrgId.ts @@ -9,7 +9,7 @@ import { Donation } from "../../models"; */ export const getDonationByOrgId: QueryResolvers["getDonationByOrgId"] = async ( _parent, - args + args, ) => { return await Donation.find({ orgId: args.orgId, diff --git a/src/resolvers/Query/getlanguage.ts b/src/resolvers/Query/getlanguage.ts index 6dcb6c94cd3..d2b108cb60d 100644 --- a/src/resolvers/Query/getlanguage.ts +++ b/src/resolvers/Query/getlanguage.ts @@ -11,7 +11,7 @@ import { Language } from "../../models"; */ export const getlanguage: QueryResolvers["getlanguage"] = async ( _parent, - args + args, ) => { const languages = await Language.find({ "translation.lang_code": args.lang_code, diff --git a/src/resolvers/Query/hasSubmittedFeedback.ts b/src/resolvers/Query/hasSubmittedFeedback.ts index ae8300bf253..803270b4e7a 100644 --- a/src/resolvers/Query/hasSubmittedFeedback.ts +++ b/src/resolvers/Query/hasSubmittedFeedback.ts @@ -18,7 +18,7 @@ export const hasSubmittedFeedback: QueryResolvers["hasSubmittedFeedback"] = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } @@ -30,7 +30,7 @@ export const hasSubmittedFeedback: QueryResolvers["hasSubmittedFeedback"] = throw new errors.NotFoundError( requestContext.translate(EVENT_NOT_FOUND_ERROR.MESSAGE), EVENT_NOT_FOUND_ERROR.CODE, - EVENT_NOT_FOUND_ERROR.PARAM + EVENT_NOT_FOUND_ERROR.PARAM, ); } @@ -44,7 +44,7 @@ export const hasSubmittedFeedback: QueryResolvers["hasSubmittedFeedback"] = throw new errors.ConflictError( requestContext.translate(USER_NOT_REGISTERED_FOR_EVENT.MESSAGE), USER_NOT_REGISTERED_FOR_EVENT.CODE, - USER_NOT_REGISTERED_FOR_EVENT.PARAM + USER_NOT_REGISTERED_FOR_EVENT.PARAM, ); } @@ -52,7 +52,7 @@ export const hasSubmittedFeedback: QueryResolvers["hasSubmittedFeedback"] = throw new errors.ConflictError( requestContext.translate(USER_NOT_CHECKED_IN.MESSAGE), USER_NOT_CHECKED_IN.CODE, - USER_NOT_CHECKED_IN.PARAM + USER_NOT_CHECKED_IN.PARAM, ); } diff --git a/src/resolvers/Query/helperFunctions/getSort.ts b/src/resolvers/Query/helperFunctions/getSort.ts index 75cc17c6b2b..1613a0f1840 100644 --- a/src/resolvers/Query/helperFunctions/getSort.ts +++ b/src/resolvers/Query/helperFunctions/getSort.ts @@ -14,7 +14,7 @@ export const getSort = ( | PostOrderByInput | UserOrderByInput > - | undefined + | undefined, ): any => { let sortPayload = {}; diff --git a/src/resolvers/Query/helperFunctions/getWhere.ts b/src/resolvers/Query/helperFunctions/getWhere.ts index a9dfbe46137..3dec0560669 100644 --- a/src/resolvers/Query/helperFunctions/getWhere.ts +++ b/src/resolvers/Query/helperFunctions/getWhere.ts @@ -32,7 +32,7 @@ export const getWhere = ( DonationWhereInput > > - | undefined + | undefined, ): FilterQuery => { let wherePayload: FilterQuery = {}; diff --git a/src/resolvers/Query/me.ts b/src/resolvers/Query/me.ts index cbeef3504e5..7bb050ce3ae 100644 --- a/src/resolvers/Query/me.ts +++ b/src/resolvers/Query/me.ts @@ -27,7 +27,7 @@ export const me: QueryResolvers["me"] = async (_parent, _args, context) => { throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.DESC, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/myLanguage.ts b/src/resolvers/Query/myLanguage.ts index 2ebbc9f768f..d0a706f4074 100644 --- a/src/resolvers/Query/myLanguage.ts +++ b/src/resolvers/Query/myLanguage.ts @@ -13,7 +13,7 @@ import { USER_NOT_FOUND_ERROR } from "../../constants"; export const myLanguage: QueryResolvers["myLanguage"] = async ( _parent, _args, - context + context, ) => { const currentUser = await User.findOne({ _id: context.userId, @@ -25,7 +25,7 @@ export const myLanguage: QueryResolvers["myLanguage"] = async ( throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.DESC, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/organizationIsSample.ts b/src/resolvers/Query/organizationIsSample.ts index a9566d876b9..bc13f70f640 100644 --- a/src/resolvers/Query/organizationIsSample.ts +++ b/src/resolvers/Query/organizationIsSample.ts @@ -13,7 +13,7 @@ export const isSampleOrganization: QueryResolvers["isSampleOrganization"] = throw new errors.UnauthorizedError( requestContext.translate(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE), ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/organizations.ts b/src/resolvers/Query/organizations.ts index a87051f9f38..6fda9615739 100644 --- a/src/resolvers/Query/organizations.ts +++ b/src/resolvers/Query/organizations.ts @@ -15,7 +15,7 @@ import { findOrganizationsInCache } from "../../services/OrganizationCache/findO */ export const organizations: QueryResolvers["organizations"] = async ( _parent, - args + args, ) => { const sort = getSort(args.orderBy); @@ -39,7 +39,7 @@ export const organizations: QueryResolvers["organizations"] = async ( throw new errors.NotFoundError( ORGANIZATION_NOT_FOUND_ERROR.DESC, ORGANIZATION_NOT_FOUND_ERROR.CODE, - ORGANIZATION_NOT_FOUND_ERROR.PARAM + ORGANIZATION_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/organizationsMemberConnection.ts b/src/resolvers/Query/organizationsMemberConnection.ts index 1f80254546d..6c96f114c12 100644 --- a/src/resolvers/Query/organizationsMemberConnection.ts +++ b/src/resolvers/Query/organizationsMemberConnection.ts @@ -54,7 +54,7 @@ export const organizationsMemberConnection: QueryResolvers["organizationsMemberC ...paginateOptions, populate: ["registeredEvents"], select: ["-password"], - } + }, ); let users = {}; diff --git a/src/resolvers/Query/post.ts b/src/resolvers/Query/post.ts index 595e09c4419..d09733e9acb 100644 --- a/src/resolvers/Query/post.ts +++ b/src/resolvers/Query/post.ts @@ -18,7 +18,7 @@ export const post: QueryResolvers["post"] = async (_parent, args) => { throw new errors.NotFoundError( POST_NOT_FOUND_ERROR.DESC, POST_NOT_FOUND_ERROR.CODE, - POST_NOT_FOUND_ERROR.PARAM + POST_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/postsByOrganizationConnection.ts b/src/resolvers/Query/postsByOrganizationConnection.ts index fd9be4ca2b3..7865cead7c0 100644 --- a/src/resolvers/Query/postsByOrganizationConnection.ts +++ b/src/resolvers/Query/postsByOrganizationConnection.ts @@ -49,7 +49,7 @@ export const postsByOrganizationConnection: QueryResolvers["postsByOrganizationC organization: args.id, ...where, }, - options + options, ); const posts = postsmodel.docs.map((post) => { diff --git a/src/resolvers/Query/user.ts b/src/resolvers/Query/user.ts index efd0d191bef..935eb4a48c4 100644 --- a/src/resolvers/Query/user.ts +++ b/src/resolvers/Query/user.ts @@ -18,7 +18,7 @@ export const user: QueryResolvers["user"] = async (_parent, args, context) => { throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.DESC, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/userLanguage.ts b/src/resolvers/Query/userLanguage.ts index 3bcab4be001..4a3213e03b3 100644 --- a/src/resolvers/Query/userLanguage.ts +++ b/src/resolvers/Query/userLanguage.ts @@ -10,7 +10,7 @@ import { USER_NOT_FOUND_ERROR } from "../../constants"; */ export const userLanguage: QueryResolvers["userLanguage"] = async ( _parent, - args + args, ) => { const user = await User.findOne({ _id: args.userId, @@ -22,7 +22,7 @@ export const userLanguage: QueryResolvers["userLanguage"] = async ( throw new errors.NotFoundError( USER_NOT_FOUND_ERROR.DESC, USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/resolvers/Query/users.ts b/src/resolvers/Query/users.ts index ab9fdfba43e..c63e174a828 100644 --- a/src/resolvers/Query/users.ts +++ b/src/resolvers/Query/users.ts @@ -17,7 +17,7 @@ import { getWhere } from "./helperFunctions/getWhere"; export const users: QueryResolvers["users"] = async ( _parent, args, - context + context, ) => { const where = getWhere(args.where); const sort = getSort(args.orderBy); @@ -30,7 +30,7 @@ export const users: QueryResolvers["users"] = async ( throw new errors.UnauthenticatedError( requestContext.translate(UNAUTHENTICATED_ERROR.MESSAGE), UNAUTHENTICATED_ERROR.CODE, - UNAUTHENTICATED_ERROR.PARAM + UNAUTHENTICATED_ERROR.PARAM, ); } const filterCriteria = { diff --git a/src/resolvers/Query/usersConnection.ts b/src/resolvers/Query/usersConnection.ts index 747712037a9..84da92c13cb 100644 --- a/src/resolvers/Query/usersConnection.ts +++ b/src/resolvers/Query/usersConnection.ts @@ -14,7 +14,7 @@ import { getWhere } from "./helperFunctions/getWhere"; */ export const usersConnection: QueryResolvers["usersConnection"] = async ( _parent, - args + args, ) => { const where = getWhere(args.where); const sort = getSort(args.orderBy); diff --git a/src/resolvers/Subscription/directMessageChat.ts b/src/resolvers/Subscription/directMessageChat.ts index 2edfcc1a572..de5a2ddeee6 100644 --- a/src/resolvers/Subscription/directMessageChat.ts +++ b/src/resolvers/Subscription/directMessageChat.ts @@ -14,6 +14,6 @@ export const directMessageChat: SubscriptionResolvers["directMessageChat"] = { subscribe: withFilter( (_parent, _args, context) => context.pubsub.asyncIterator(CHAT_CHANNEL), - (payload) => payload?.directMessageChat + (payload) => payload?.directMessageChat, ), }; diff --git a/src/resolvers/Subscription/messageSentToDirectChat.ts b/src/resolvers/Subscription/messageSentToDirectChat.ts index 8316689123b..465671dd730 100644 --- a/src/resolvers/Subscription/messageSentToDirectChat.ts +++ b/src/resolvers/Subscription/messageSentToDirectChat.ts @@ -25,6 +25,6 @@ export const messageSentToDirectChat: SubscriptionResolvers["messageSentToDirect (_parent, _args, context) => context.pubsub.asyncIterator([MESSAGE_SENT_TO_DIRECT_CHAT]), - (payload, _variables, context) => filterFunction(payload, context) + (payload, _variables, context) => filterFunction(payload, context), ), }; diff --git a/src/resolvers/Subscription/messageSentToGroupChat.ts b/src/resolvers/Subscription/messageSentToGroupChat.ts index 20c83454de5..6d1bb5ba692 100644 --- a/src/resolvers/Subscription/messageSentToGroupChat.ts +++ b/src/resolvers/Subscription/messageSentToGroupChat.ts @@ -6,7 +6,7 @@ const MESSAGE_SENT_TO_GROUP_CHAT = "MESSAGE_SENT_TO_GROUP_CHAT"; export const filterFunction = async function ( payload: any, - context: any + context: any, ): Promise { const { currentUserId } = context.context; const groupChatId = payload.messageSentToGroupChat.groupChatMessageBelongsTo; @@ -17,7 +17,7 @@ export const filterFunction = async function ( if (groupChat) { const currentUserIsGroupChatMember = groupChat.users.some((user) => - user.equals(currentUserId) + user.equals(currentUserId), ); return currentUserIsGroupChatMember; } else { @@ -39,6 +39,6 @@ export const messageSentToGroupChat: SubscriptionResolvers["messageSentToGroupCh (_parent, _args, context) => context.pubsub.asyncIterator([MESSAGE_SENT_TO_GROUP_CHAT]), - (payload, _variables, context) => filterFunction(payload, context) + (payload, _variables, context) => filterFunction(payload, context), ), }; diff --git a/src/resolvers/Subscription/onPluginUpdate.ts b/src/resolvers/Subscription/onPluginUpdate.ts index 9d52ff1b0a5..9756f2709b6 100644 --- a/src/resolvers/Subscription/onPluginUpdate.ts +++ b/src/resolvers/Subscription/onPluginUpdate.ts @@ -20,7 +20,7 @@ export const filterFunction = async function ( // eslint-disable-next-line @typescript-eslint/no-unused-vars payload: any, // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: any + context: any, ): Promise { return true; }; @@ -30,7 +30,7 @@ export const onPluginUpdate: SubscriptionResolvers["onPluginUpdate"] = { subscribe: withFilter( (_parent, _args, context) => context.pubsub.asyncIterator([TALAWA_PLUGIN_UPDATED]), - (payload, _variables, context) => filterFunction(payload, context) + (payload, _variables, context) => filterFunction(payload, context), ), resolve: (payload: any) => { return payload.Plugin; diff --git a/src/resolvers/UserTag/childTags.ts b/src/resolvers/UserTag/childTags.ts index 5dd1846d2e0..436857f859f 100644 --- a/src/resolvers/UserTag/childTags.ts +++ b/src/resolvers/UserTag/childTags.ts @@ -11,7 +11,7 @@ import { validatePaginationArgs } from "../../libraries/validators/validatePagin export const childTags: UserTagResolvers["childTags"] = async ( parent, - args + args, ) => { const errors = validatePaginationArgs(args.input); @@ -49,7 +49,7 @@ export const childTags: UserTagResolvers["childTags"] = async ( // The default sorting logic of ascending order by MongoID should always be provided _id: 1, name: 1, - }) + }), ) .limit(getLimit(args.input.limit)) .lean(); diff --git a/src/resolvers/UserTag/organization.ts b/src/resolvers/UserTag/organization.ts index e97403aba46..b38ead05406 100644 --- a/src/resolvers/UserTag/organization.ts +++ b/src/resolvers/UserTag/organization.ts @@ -2,7 +2,7 @@ import type { UserTagResolvers } from "../../types/generatedGraphQLTypes"; import { Organization } from "../../models"; export const organization: UserTagResolvers["organization"] = async ( - parent + parent, ) => { return await Organization.findOne({ _id: parent.organizationId, diff --git a/src/resolvers/UserTag/usersAssignedTo.ts b/src/resolvers/UserTag/usersAssignedTo.ts index b2f91e90d4a..d1da82b4460 100644 --- a/src/resolvers/UserTag/usersAssignedTo.ts +++ b/src/resolvers/UserTag/usersAssignedTo.ts @@ -11,7 +11,7 @@ import { validatePaginationArgs } from "../../libraries/validators/validatePagin export const usersAssignedTo: UserTagResolvers["usersAssignedTo"] = async ( parent, - args + args, ) => { const errors = validatePaginationArgs(args.input); @@ -48,7 +48,7 @@ export const usersAssignedTo: UserTagResolvers["usersAssignedTo"] = async ( getSortingObject(args.input.direction, { // The default sorting logic of ascending order by MongoID should always be provided _id: 1, - }) + }), ) .limit(getLimit(args.input.limit)) .populate("userId") @@ -57,6 +57,6 @@ export const usersAssignedTo: UserTagResolvers["usersAssignedTo"] = async ( return generateConnectionObject( args.input, allUserObjects, - (userTag) => userTag.userId + (userTag) => userTag.userId, ); }; diff --git a/src/resolvers/middleware/currentUserExists.ts b/src/resolvers/middleware/currentUserExists.ts index 348c6acf73e..2e56d0664ab 100644 --- a/src/resolvers/middleware/currentUserExists.ts +++ b/src/resolvers/middleware/currentUserExists.ts @@ -16,7 +16,7 @@ export const currentUserExists = throw new errors.NotFoundError( requestContext.translate(USER_NOT_FOUND_ERROR.MESSAGE), USER_NOT_FOUND_ERROR.CODE, - USER_NOT_FOUND_ERROR.PARAM + USER_NOT_FOUND_ERROR.PARAM, ); } diff --git a/src/services/CommentCache/cacheComments.ts b/src/services/CommentCache/cacheComments.ts index 36021dffdc6..bfe9cd6d530 100644 --- a/src/services/CommentCache/cacheComments.ts +++ b/src/services/CommentCache/cacheComments.ts @@ -4,7 +4,7 @@ import CommentCache from "../redisCache"; // Function to store comments in the cache using pipelining export async function cacheComments( - comments: InterfaceComment[] + comments: InterfaceComment[], ): Promise { try { const pipeline = CommentCache.pipeline(); diff --git a/src/services/CommentCache/deleteCommentFromCache.ts b/src/services/CommentCache/deleteCommentFromCache.ts index f249ac9ba48..30f8914e6d6 100644 --- a/src/services/CommentCache/deleteCommentFromCache.ts +++ b/src/services/CommentCache/deleteCommentFromCache.ts @@ -2,7 +2,7 @@ import CommentCache from "../redisCache"; import type { InterfaceComment } from "../../models"; export async function deleteCommentFromCache( - comment: InterfaceComment + comment: InterfaceComment, ): Promise { const key = `comment:${comment._id}`; diff --git a/src/services/CommentCache/findCommentsByPostIdInCache.ts b/src/services/CommentCache/findCommentsByPostIdInCache.ts index 4d0576d1b54..4b10914332c 100644 --- a/src/services/CommentCache/findCommentsByPostIdInCache.ts +++ b/src/services/CommentCache/findCommentsByPostIdInCache.ts @@ -4,7 +4,7 @@ import { Types } from "mongoose"; import { logger } from "../../libraries"; export async function findCommentsByPostIdInCache( - postID: Types.ObjectId + postID: Types.ObjectId, ): Promise<(InterfaceComment | null)[]> { if (!postID) { return [null]; diff --git a/src/services/CommentCache/findCommentsInCache.ts b/src/services/CommentCache/findCommentsInCache.ts index 2789497d48b..bacae081db8 100644 --- a/src/services/CommentCache/findCommentsInCache.ts +++ b/src/services/CommentCache/findCommentsInCache.ts @@ -4,7 +4,7 @@ import { Types } from "mongoose"; import { logger } from "../../libraries"; export async function findCommentsInCache( - ids: string[] + ids: string[], ): Promise<(InterfaceComment | null)[]> { if (ids.length === 0) { return [null]; diff --git a/src/services/EventCache/deleteEventFromCache.ts b/src/services/EventCache/deleteEventFromCache.ts index 8affeee4519..0f36da3cce9 100644 --- a/src/services/EventCache/deleteEventFromCache.ts +++ b/src/services/EventCache/deleteEventFromCache.ts @@ -2,7 +2,7 @@ import EventCache from "../redisCache"; import type { Types } from "mongoose"; export async function deleteEventFromCache( - eventId: Types.ObjectId + eventId: Types.ObjectId, ): Promise { const key = `event:${eventId}`; diff --git a/src/services/EventCache/findEventInCache.ts b/src/services/EventCache/findEventInCache.ts index e40dc069666..0c3ff96c616 100644 --- a/src/services/EventCache/findEventInCache.ts +++ b/src/services/EventCache/findEventInCache.ts @@ -4,7 +4,7 @@ import { Types } from "mongoose"; import { logger } from "../../libraries"; export async function findEventsInCache( - ids: string[] + ids: string[], ): Promise<(InterfaceEvent | null)[]> { if (ids.length === 0) { return [null]; diff --git a/src/services/OrganizationCache/cacheOrganizations.ts b/src/services/OrganizationCache/cacheOrganizations.ts index 6a0fb4720da..6620ce04cfc 100644 --- a/src/services/OrganizationCache/cacheOrganizations.ts +++ b/src/services/OrganizationCache/cacheOrganizations.ts @@ -4,7 +4,7 @@ import OrganizationCache from "../redisCache"; // Function to store organizations in the cache using pipelining export async function cacheOrganizations( - organizations: InterfaceOrganization[] + organizations: InterfaceOrganization[], ): Promise { try { const pipeline = OrganizationCache.pipeline(); diff --git a/src/services/OrganizationCache/deleteOrganizationFromCache.ts b/src/services/OrganizationCache/deleteOrganizationFromCache.ts index 6359664ea18..030b13c64fa 100644 --- a/src/services/OrganizationCache/deleteOrganizationFromCache.ts +++ b/src/services/OrganizationCache/deleteOrganizationFromCache.ts @@ -2,7 +2,7 @@ import OrganizationCache from "../redisCache"; import type { InterfaceOrganization } from "../../models"; export async function deleteOrganizationFromCache( - organization: InterfaceOrganization + organization: InterfaceOrganization, ): Promise { const key = `organization:${organization._id}`; diff --git a/src/services/OrganizationCache/findOrganizationsInCache.ts b/src/services/OrganizationCache/findOrganizationsInCache.ts index 5812fa8827b..5eb9b61638e 100644 --- a/src/services/OrganizationCache/findOrganizationsInCache.ts +++ b/src/services/OrganizationCache/findOrganizationsInCache.ts @@ -4,7 +4,7 @@ import { Types } from "mongoose"; import { logger } from "../../libraries"; export async function findOrganizationsInCache( - ids: string[] + ids: string[], ): Promise<(InterfaceOrganization | null)[]> { if (ids.length === 0) { return [null]; @@ -78,7 +78,7 @@ export async function findOrganizationsInCache( ? organization.membershipRequests.map( (membershipRequest: string) => { return Types.ObjectId(membershipRequest); - } + }, ) : [], diff --git a/src/services/PostCache/findPostsInCache.ts b/src/services/PostCache/findPostsInCache.ts index 5f1de8393ee..204dc2f25d1 100644 --- a/src/services/PostCache/findPostsInCache.ts +++ b/src/services/PostCache/findPostsInCache.ts @@ -4,7 +4,7 @@ import { Types } from "mongoose"; import { logger } from "../../libraries"; export async function findPostsInCache( - ids: string[] + ids: string[], ): Promise<(InterfacePost | null)[]> { if (ids.length === 0) { return [null]; diff --git a/src/utilities/PII/decryption.ts b/src/utilities/PII/decryption.ts index a30f4257aa3..d93b505ec82 100644 --- a/src/utilities/PII/decryption.ts +++ b/src/utilities/PII/decryption.ts @@ -4,12 +4,12 @@ import crypto from "crypto"; export function decrypt( encryptedText: string, key: string, - iv: string + iv: string, ): string { const decipher = crypto.createDecipheriv( "aes-256-cbc", Buffer.from(key), - Buffer.from(iv, "hex") + Buffer.from(iv, "hex"), ); let decrypted = decipher.update(encryptedText, "hex", "utf8"); decrypted += decipher.final("utf8"); diff --git a/src/utilities/PII/encryption.ts b/src/utilities/PII/encryption.ts index 4fb600985f4..05c85bd86a2 100644 --- a/src/utilities/PII/encryption.ts +++ b/src/utilities/PII/encryption.ts @@ -5,7 +5,7 @@ export function encrypt(text: string, key: string, iv: string): string { const cipher = crypto.createCipheriv( "aes-256-cbc", Buffer.from(key), - Buffer.from(iv, "hex") + Buffer.from(iv, "hex"), ); let encrypted = cipher.update(text); encrypted = Buffer.concat([encrypted, cipher.final()]); diff --git a/src/utilities/PII/isAuthorised.ts b/src/utilities/PII/isAuthorised.ts index ad3e2468026..65c4120de52 100644 --- a/src/utilities/PII/isAuthorised.ts +++ b/src/utilities/PII/isAuthorised.ts @@ -2,7 +2,7 @@ import type { User } from "../../types/generatedGraphQLTypes"; export function isAuthorised( requestingUser: User, - requestedUser: User + requestedUser: User, ): boolean { if (requestedUser !== requestedUser) { return false; diff --git a/src/utilities/adminCheck.ts b/src/utilities/adminCheck.ts index bd44cd28e10..68f77493301 100644 --- a/src/utilities/adminCheck.ts +++ b/src/utilities/adminCheck.ts @@ -13,10 +13,10 @@ import { User } from "../models"; */ export const adminCheck = async ( userId: string | Types.ObjectId, - organization: InterfaceOrganization + organization: InterfaceOrganization, ): Promise => { const userIsOrganizationAdmin = organization.admins.some( - (admin) => admin === userId || Types.ObjectId(admin).equals(userId) + (admin) => admin === userId || Types.ObjectId(admin).equals(userId), ); const user = await User.findOne({ @@ -30,7 +30,7 @@ export const adminCheck = async ( throw new errors.UnauthorizedError( requestContext.translate(`${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`), USER_NOT_AUTHORIZED_ADMIN.CODE, - USER_NOT_AUTHORIZED_ADMIN.PARAM + USER_NOT_AUTHORIZED_ADMIN.PARAM, ); } }; diff --git a/src/utilities/auth.ts b/src/utilities/auth.ts index d8db27a3a44..bb7305d650c 100644 --- a/src/utilities/auth.ts +++ b/src/utilities/auth.ts @@ -28,7 +28,7 @@ export const createAccessToken = (user: InterfaceUser): string => { ACCESS_TOKEN_SECRET as string, { expiresIn: "40m", - } + }, ); }; @@ -44,7 +44,7 @@ export const createRefreshToken = (user: InterfaceUser): string => { REFRESH_TOKEN_SECRET as string, { expiresIn: "30d", - } + }, ); }; diff --git a/src/utilities/createSampleOrganizationUtil.ts b/src/utilities/createSampleOrganizationUtil.ts index ee67fe7d73f..95861eb6c73 100644 --- a/src/utilities/createSampleOrganizationUtil.ts +++ b/src/utilities/createSampleOrganizationUtil.ts @@ -9,7 +9,7 @@ import { SampleData } from "../models/SampleData"; export const generateUserData = async ( organizationId: string, - userType: string + userType: string, ): Promise> => { const gender: "male" | "female" = faker.helpers.arrayElement([ "male", @@ -29,7 +29,7 @@ export const generateUserData = async ( firstName: fname, lastName: lname, email: `${fname.toLowerCase()}${lname.toLowerCase()}@${faker.helpers.arrayElement( - ["xyz", "abc", "lmnop"] + ["xyz", "abc", "lmnop"], )}.com`, password: "$2a$12$bSYpay6TRMpTOaAmYPFXku4avwmqfFBtmgg39TabxmtFEiz4plFtW", joinedOrganizations: [organizationId], @@ -50,7 +50,7 @@ export const generateUserData = async ( }; const createUser = async ( - generatedUser: InterfaceUser & mongoose.Document + generatedUser: InterfaceUser & mongoose.Document, ): Promise> => { const savedUser = await generatedUser.save(); const sampleModel = new SampleData({ @@ -63,7 +63,7 @@ const createUser = async ( export const generateEventData = async ( users: InterfaceUser[], - organizationId: string + organizationId: string, ): Promise => { const today = new Date(); const oneWeekFromNow = new Date(); @@ -76,7 +76,7 @@ export const generateEventData = async ( const duration = Math.floor(Math.random() * 7) + 1; // Random duration between 1 and 7 days const endDate = new Date( - startDate.getTime() + duration * 24 * 60 * 60 * 1000 + startDate.getTime() + duration * 24 * 60 * 60 * 1000, ); const event = new Event({ @@ -119,7 +119,7 @@ export const generateEventData = async ( await User.findByIdAndUpdate( creatorId, { $push: { eventsCreated: event._id } }, - { new: true } + { new: true }, ); return event; @@ -127,7 +127,7 @@ export const generateEventData = async ( export const generatePostData = async ( users: InterfaceUser[], - organizationId: string + organizationId: string, ): Promise> => { const post = new Post({ status: "ACTIVE", @@ -158,7 +158,7 @@ export const generatePostData = async ( const createPosts = async ( numPosts: number, users: InterfaceUser[], - organizationId: string + organizationId: string, ): Promise<(InterfacePost & mongoose.Document)[]> => { const posts = []; for (let i = 0; i < numPosts; i++) { @@ -171,7 +171,7 @@ const createPosts = async ( const createEvents = async ( numEvents: number, users: InterfaceUser[], - organizationId: string + organizationId: string, ): Promise => { const events = []; @@ -184,7 +184,7 @@ const createEvents = async ( export const generateRandomPlugins = async ( numberOfPlugins: number, - users: string[] + users: string[], ): Promise[]> => { const pluginPromises = []; for (let i = 0; i < numberOfPlugins; i++) { diff --git a/src/utilities/deleteImage.ts b/src/utilities/deleteImage.ts index d8346e25365..74c30cba1fd 100644 --- a/src/utilities/deleteImage.ts +++ b/src/utilities/deleteImage.ts @@ -11,14 +11,14 @@ import { reuploadDuplicateCheck } from "./reuploadDuplicateCheck"; */ export const deleteImage = async ( imageToBeDeleted: string, - imageBelongingToItem?: string + imageBelongingToItem?: string, ): Promise => { let imageIsDuplicate = false; if (imageBelongingToItem) { imageIsDuplicate = await reuploadDuplicateCheck( imageToBeDeleted, - imageBelongingToItem + imageBelongingToItem, ); } @@ -55,7 +55,7 @@ export const deleteImage = async ( $inc: { numberOfUses: -1, }, - } + }, ); } }; diff --git a/src/utilities/encodedImageStorage/deletePreviousImage.ts b/src/utilities/encodedImageStorage/deletePreviousImage.ts index e22f64de44d..33d600f6590 100644 --- a/src/utilities/encodedImageStorage/deletePreviousImage.ts +++ b/src/utilities/encodedImageStorage/deletePreviousImage.ts @@ -3,7 +3,7 @@ import path from "path"; import { EncodedImage } from "../../models/EncodedImage"; export const deletePreviousImage = async ( - imageToBeDeletedPath: string + imageToBeDeletedPath: string, ): Promise => { const imageToBeDeleted = await EncodedImage.findOne({ fileName: imageToBeDeletedPath!, @@ -24,6 +24,6 @@ export const deletePreviousImage = async ( $inc: { numberOfUses: -1, }, - } + }, ); }; diff --git a/src/utilities/encodedImageStorage/encodedImageExtensionCheck.ts b/src/utilities/encodedImageStorage/encodedImageExtensionCheck.ts index 3e7b25e1314..bc6256012ed 100644 --- a/src/utilities/encodedImageStorage/encodedImageExtensionCheck.ts +++ b/src/utilities/encodedImageStorage/encodedImageExtensionCheck.ts @@ -1,7 +1,7 @@ export const encodedImageExtentionCheck = (encodedUrl: string): boolean => { const extension = encodedUrl.substring( "data:".length, - encodedUrl.indexOf(";base64") + encodedUrl.indexOf(";base64"), ); console.log(extension); diff --git a/src/utilities/encodedImageStorage/uploadEncodedImage.ts b/src/utilities/encodedImageStorage/uploadEncodedImage.ts index d3710f12461..eb16df6bae8 100644 --- a/src/utilities/encodedImageStorage/uploadEncodedImage.ts +++ b/src/utilities/encodedImageStorage/uploadEncodedImage.ts @@ -25,7 +25,7 @@ const base64SizeInKb = (base64String: string): number => { export const uploadEncodedImage = async ( encodedImageURL: string, - previousImagePath?: string | null + previousImagePath?: string | null, ): Promise => { const isURLValidImage = encodedImageExtentionCheck(encodedImageURL); @@ -39,7 +39,7 @@ export const uploadEncodedImage = async ( throw new errors.ImageSizeLimitExceeded( IMAGE_SIZE_LIMIT_KB.MESSAGE, IMAGE_SIZE_LIMIT_KB.CODE, - IMAGE_SIZE_LIMIT_KB.PARAM + IMAGE_SIZE_LIMIT_KB.PARAM, ); } @@ -47,7 +47,7 @@ export const uploadEncodedImage = async ( throw new errors.InvalidFileTypeError( requestContext.translate(INVALID_FILE_TYPE.MESSAGE), INVALID_FILE_TYPE.CODE, - INVALID_FILE_TYPE.PARAM + INVALID_FILE_TYPE.PARAM, ); } @@ -68,7 +68,7 @@ export const uploadEncodedImage = async ( $inc: { numberOfUses: 1, }, - } + }, ); if (previousImagePath) { diff --git a/src/utilities/encodedVideoStorage/deletePreviousVideo.ts b/src/utilities/encodedVideoStorage/deletePreviousVideo.ts index 2fbcf3539b8..4cbdf3a88d6 100644 --- a/src/utilities/encodedVideoStorage/deletePreviousVideo.ts +++ b/src/utilities/encodedVideoStorage/deletePreviousVideo.ts @@ -3,7 +3,7 @@ import path from "path"; import { EncodedVideo } from "../../models/EncodedVideo"; export const deletePreviousVideo = async ( - videoToBeDeletedPath: string + videoToBeDeletedPath: string, ): Promise => { const videoToBeDeleted = await EncodedVideo.findOne({ fileName: videoToBeDeletedPath!, @@ -24,6 +24,6 @@ export const deletePreviousVideo = async ( $inc: { numberOfUses: -1, }, - } + }, ); }; diff --git a/src/utilities/encodedVideoStorage/encodedVideoExtensionCheck.ts b/src/utilities/encodedVideoStorage/encodedVideoExtensionCheck.ts index 85d6f854abd..f9cb626d043 100644 --- a/src/utilities/encodedVideoStorage/encodedVideoExtensionCheck.ts +++ b/src/utilities/encodedVideoStorage/encodedVideoExtensionCheck.ts @@ -1,7 +1,7 @@ export const encodedVideoExtentionCheck = (encodedUrl: string): boolean => { const extension = encodedUrl.substring( "data:".length, - encodedUrl.indexOf(";base64") + encodedUrl.indexOf(";base64"), ); console.log(extension); diff --git a/src/utilities/encodedVideoStorage/uploadEncodedVideo.ts b/src/utilities/encodedVideoStorage/uploadEncodedVideo.ts index 23460486744..faf69f78aed 100644 --- a/src/utilities/encodedVideoStorage/uploadEncodedVideo.ts +++ b/src/utilities/encodedVideoStorage/uploadEncodedVideo.ts @@ -11,7 +11,7 @@ import { deletePreviousVideo } from "./deletePreviousVideo"; export const uploadEncodedVideo = async ( encodedVideoURL: string, // eslint-disable-next-line @typescript-eslint/no-unused-vars - previousVideoPath?: string | null + previousVideoPath?: string | null, ): Promise => { const isURLValidVideo = encodedVideoExtentionCheck(encodedVideoURL); @@ -19,7 +19,7 @@ export const uploadEncodedVideo = async ( throw new errors.InvalidFileTypeError( requestContext.translate(INVALID_FILE_TYPE.MESSAGE), INVALID_FILE_TYPE.CODE, - INVALID_FILE_TYPE.PARAM + INVALID_FILE_TYPE.PARAM, ); } @@ -40,7 +40,7 @@ export const uploadEncodedVideo = async ( $inc: { numberOfUses: 1, }, - } + }, ); if (previousVideoPath) { diff --git a/src/utilities/graphqlConnectionFactory.ts b/src/utilities/graphqlConnectionFactory.ts index 3181a921e84..d5c11bac284 100644 --- a/src/utilities/graphqlConnectionFactory.ts +++ b/src/utilities/graphqlConnectionFactory.ts @@ -52,7 +52,7 @@ export const getLimit = (limit: number): number => { // Generates the sortingObject that can be passed in the .sort() method export const getSortingObject = ( direction: "FORWARD" | "BACKWARD", - sortingObject: Record + sortingObject: Record, ): Record => { // We assume that the resolver would always be written with respect to the sorting that needs to be implemented for forward pagination if (direction === "FORWARD") return sortingObject; @@ -73,7 +73,7 @@ type FilterObjectType = { // Generates the sorting arguments for filterQuery that can be passed into the .find() method export function getFilterObject( - args: CursorPaginationInput + args: CursorPaginationInput, ): FilterObjectType | null { if (args.cursor) { if (args.direction === "FORWARD") return { _id: { $gt: args.cursor } }; @@ -105,11 +105,11 @@ The function returns a promise which would resolve to the desired connection obj */ export function generateConnectionObject< T1 extends { _id: Types.ObjectId }, - T2 extends { _id: Types.ObjectId } + T2 extends { _id: Types.ObjectId }, >( args: CursorPaginationInput, allFetchedObjects: T2[] | null, - getNodeFromResult: GetNodeFromResultFnType + getNodeFromResult: GetNodeFromResultFnType, ): InterfaceConnectionResult { // Initialize the connection object const connectionObject = graphqlConnectionFactory(); diff --git a/src/utilities/imageAlreadyInDbCheck.ts b/src/utilities/imageAlreadyInDbCheck.ts index 93967626e53..69822377080 100644 --- a/src/utilities/imageAlreadyInDbCheck.ts +++ b/src/utilities/imageAlreadyInDbCheck.ts @@ -15,7 +15,7 @@ import { INVALID_FILE_TYPE } from "../constants"; */ export const imageAlreadyInDbCheck = async ( oldImagePath: string | null, - newImagePath: string + newImagePath: string, ): Promise => { try { let fileName; @@ -46,7 +46,7 @@ export const imageAlreadyInDbCheck = async ( } else { const imageIsDuplicate = await reuploadDuplicateCheck( oldImagePath, - newImagePath + newImagePath, ); if (imageIsDuplicate === false) { @@ -60,7 +60,7 @@ export const imageAlreadyInDbCheck = async ( $inc: { numberOfUses: 1, }, - } + }, ); } @@ -79,7 +79,7 @@ export const imageAlreadyInDbCheck = async ( param: INVALID_FILE_TYPE.PARAM, }, ], - requestContext.translate(INVALID_FILE_TYPE.MESSAGE) + requestContext.translate(INVALID_FILE_TYPE.MESSAGE), ); } }; diff --git a/src/utilities/imageExtensionCheck.ts b/src/utilities/imageExtensionCheck.ts index f2e37b3d37c..337e3f806dc 100644 --- a/src/utilities/imageExtensionCheck.ts +++ b/src/utilities/imageExtensionCheck.ts @@ -25,7 +25,7 @@ export const imageExtensionCheck = async (filename: string): Promise => { param: INVALID_FILE_TYPE.PARAM, }, ], - requestContext.translate(INVALID_FILE_TYPE.MESSAGE) + requestContext.translate(INVALID_FILE_TYPE.MESSAGE), ); } }; diff --git a/src/utilities/loadSampleData.ts b/src/utilities/loadSampleData.ts index eaa0a62158d..eb1992fe97d 100644 --- a/src/utilities/loadSampleData.ts +++ b/src/utilities/loadSampleData.ts @@ -51,7 +51,7 @@ async function insertCollections(collections: string[]): Promise { for (const collection of collections) { const data = await fs.readFile( path.join(__dirname, `../../sample_data/${collection}.json`), - "utf8" + "utf8", ); const docs = JSON.parse(data) as Record[]; diff --git a/src/utilities/mailer.ts b/src/utilities/mailer.ts index a4d44bda49f..f7b5f93bd34 100644 --- a/src/utilities/mailer.ts +++ b/src/utilities/mailer.ts @@ -22,7 +22,7 @@ export interface InterfaceMailFields { * @returns Promise along with resolve and reject methods. */ export const mailer = ( - mailFields: InterfaceMailFields + mailFields: InterfaceMailFields, ): Promise => { // Nodemailer configuration let transporter: Transporter; @@ -68,7 +68,7 @@ export const mailer = ( } else { resolve(info); } - } + }, ); }); }; diff --git a/src/utilities/reuploadDuplicateCheck.ts b/src/utilities/reuploadDuplicateCheck.ts index 53adaa9ab05..b56944b3642 100644 --- a/src/utilities/reuploadDuplicateCheck.ts +++ b/src/utilities/reuploadDuplicateCheck.ts @@ -41,7 +41,7 @@ const getImageHash = (oldSrc: TypeImagePath): object => { */ export const reuploadDuplicateCheck = async ( oldImagePath: TypeImagePath | null, - newImagePath: TypeImagePath + newImagePath: TypeImagePath, ): Promise => { /* This function checks whether a user is trying to re-upload the same profile picture @@ -68,7 +68,7 @@ export const reuploadDuplicateCheck = async ( param: "fileType", }, ], - requestContext.translate("invalid.fileType") + requestContext.translate("invalid.fileType"), ); } }; diff --git a/src/utilities/superAdminCheck.ts b/src/utilities/superAdminCheck.ts index 1b6c52f5800..1f3cad55841 100644 --- a/src/utilities/superAdminCheck.ts +++ b/src/utilities/superAdminCheck.ts @@ -9,7 +9,7 @@ export const superAdminCheck = (user: InterfaceUser): void => { throw new errors.UnauthorizedError( requestContext.translate(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE), USER_NOT_AUTHORIZED_SUPERADMIN.CODE, - USER_NOT_AUTHORIZED_SUPERADMIN.PARAM + USER_NOT_AUTHORIZED_SUPERADMIN.PARAM, ); } }; diff --git a/src/utilities/uploadImage.ts b/src/utilities/uploadImage.ts index 1a573dff35a..91228488587 100644 --- a/src/utilities/uploadImage.ts +++ b/src/utilities/uploadImage.ts @@ -15,7 +15,7 @@ import { imageExtensionCheck } from "./imageExtensionCheck"; */ export const uploadImage = async ( newImageFile: any, - oldImagePath: string | null + oldImagePath: string | null, ): Promise<{ newImagePath: string; imageAlreadyInDbPath: string }> => { const id = shortid.generate(); @@ -29,16 +29,16 @@ export const uploadImage = async ( createReadStream() .pipe( createWriteStream( - path.join(__dirname, "../../images", `/${id}-${filename}`) - ) + path.join(__dirname, "../../images", `/${id}-${filename}`), + ), ) .on("close", resolve) .on("error", (error: any) => reject(error)) .on("finish", () => resolve({ path, - }) - ) + }), + ), ); const newImagePath = `images/${id}-${filename}`; @@ -54,7 +54,7 @@ export const uploadImage = async ( const imageAlreadyInDbPath = await imageAlreadyInDbCheck( oldImagePath, - newImagePath + newImagePath, ); return { diff --git a/tests/directives/directiveTransformer/authDirectiveTransformer.spec.ts b/tests/directives/directiveTransformer/authDirectiveTransformer.spec.ts index 4e20a68c502..42ed691d3ac 100644 --- a/tests/directives/directiveTransformer/authDirectiveTransformer.spec.ts +++ b/tests/directives/directiveTransformer/authDirectiveTransformer.spec.ts @@ -89,7 +89,7 @@ it("throws UnauthenticatedError when context is expired", async () => { }, { contextValue: authenticatedContext, - } + }, ); } catch (err) { if (err instanceof errors.UnauthenticatedError) { @@ -126,7 +126,7 @@ it("throws UnauthenticatedError when context: isAuth == false", async () => { }, { contextValue: authenticatedContext, - } + }, ); } catch (err) { if (err instanceof errors.UnauthenticatedError) { @@ -163,7 +163,7 @@ it("checks if the resolver is supplied, and return null data, if not", async () }, { contextValue: authenticatedContext, - } + }, ); //@ts-ignore @@ -198,7 +198,7 @@ it("returns data if isAuth == true and expire == false", async () => { }, { contextValue: authenticatedContext, - } + }, ); //@ts-ignore expect(result.body.singleResult.data).toEqual({ hello: "hi" }); diff --git a/tests/directives/directiveTransformer/roleDirectiveTransformer.spec.ts b/tests/directives/directiveTransformer/roleDirectiveTransformer.spec.ts index 204eafd918e..d5580849617 100644 --- a/tests/directives/directiveTransformer/roleDirectiveTransformer.spec.ts +++ b/tests/directives/directiveTransformer/roleDirectiveTransformer.spec.ts @@ -103,7 +103,7 @@ it("throws NotFoundError if no user exists with _id === context.userId", async ( }, { contextValue: authenticatedContext, - } + }, ); } catch (err) { if (err instanceof errors.NotFoundError) { @@ -143,7 +143,7 @@ it("throws UnauthenticatedError if user exists but userType != requires", async }, { contextValue: authenticatedContext, - } + }, ); //@ts-ignore @@ -185,7 +185,7 @@ it("returns data if user exists and userType === requires", async () => { }, { contextValue: authenticatedContext, - } + }, ); //@ts-ignore @@ -223,7 +223,7 @@ it("checks if the resolver is supplied, and return null data, if not", async () }, { contextValue: authenticatedContext, - } + }, ); //@ts-ignore diff --git a/tests/helpers/actionItem.ts b/tests/helpers/actionItem.ts index 1ebb112f69b..a896cb87a30 100644 --- a/tests/helpers/actionItem.ts +++ b/tests/helpers/actionItem.ts @@ -20,7 +20,7 @@ export const createTestActionItem = async (): Promise< TestOrganizationType, TestActionItemCategoryType, TestActionItemType, - TestUserType + TestUserType, ] > => { const [testUser, testOrganization] = await createTestUserAndOrganization(); @@ -103,7 +103,7 @@ export const createTestActionItems = async (): Promise< }, { eventId: testEvent?._id, - } + }, ); await ActionItem.updateOne( @@ -112,7 +112,7 @@ export const createTestActionItems = async (): Promise< }, { eventId: testEvent?._id, - } + }, ); return [testUser, testEvent, testOrganization]; diff --git a/tests/helpers/advertisement.ts b/tests/helpers/advertisement.ts index e169a33e4f1..4073afda649 100644 --- a/tests/helpers/advertisement.ts +++ b/tests/helpers/advertisement.ts @@ -30,7 +30,7 @@ export const createTestAdvertisement = // Create test advertisement in the database const createdAdvertisement = await Advertisement.create( - testAdvertisementData + testAdvertisementData, ); return createdAdvertisement.toObject(); diff --git a/tests/helpers/checkIn.ts b/tests/helpers/checkIn.ts index ae82ee1a5fd..45b3d912a35 100644 --- a/tests/helpers/checkIn.ts +++ b/tests/helpers/checkIn.ts @@ -35,7 +35,7 @@ export const createEventWithCheckedInUser = async (): Promise< }, { checkInId: checkIn!._id, - } + }, ); return [testUser, testOrg, testEvent, checkIn]; diff --git a/tests/helpers/db.ts b/tests/helpers/db.ts index 186f4983429..b34d71cb3fe 100644 --- a/tests/helpers/db.ts +++ b/tests/helpers/db.ts @@ -3,7 +3,7 @@ import mongoose from "mongoose"; // Returns a mongoose instance to the testing database export async function connect( - dbName = "TALAWA_API_TEST_DATABASE" + dbName = "TALAWA_API_TEST_DATABASE", ): Promise { return await mongoose.connect(process.env.MONGO_DB_URL as string, { dbName, @@ -15,7 +15,7 @@ export async function connect( } export async function dropAllCollectionsFromDatabase( - mongooseInstance: typeof mongoose + mongooseInstance: typeof mongoose, ): Promise { const collections = await mongooseInstance.connection.db.collections(); @@ -25,14 +25,14 @@ export async function dropAllCollectionsFromDatabase( } export async function dropDatabase( - mongooseInstance: typeof mongoose + mongooseInstance: typeof mongoose, ): Promise { await mongooseInstance.connection.db.dropDatabase(); } // Disconnects from the provided mongoose instance export async function disconnect( - mongooseInstance: typeof mongoose + mongooseInstance: typeof mongoose, ): Promise { await mongooseInstance.connection.close(); } diff --git a/tests/helpers/directChat.ts b/tests/helpers/directChat.ts index f5952dbef1d..2dd85526892 100644 --- a/tests/helpers/directChat.ts +++ b/tests/helpers/directChat.ts @@ -39,7 +39,7 @@ export const createTestDirectChatMessage = async (): Promise< TestUserType, TestOrganizationType, TestDirectChatType, - TestDirectChatMessageType + TestDirectChatMessageType, ] > => { const [testUser, testOrganization, testDirectChat] = @@ -61,7 +61,7 @@ export const createTestDirectChatMessage = async (): Promise< export const createTestDirectMessageForMultipleUser = async ( senderId: string, receiverId: string, - organizationId: string + organizationId: string, ): Promise => { const testDirectChat = await DirectChat.create({ creatorId: senderId, @@ -82,7 +82,7 @@ export const createTestDirectMessageForMultipleUser = async ( export const createTestDirectChatwithUsers = async ( creator: string, organizationId: string, - users: string[] + users: string[], ): Promise => { const testDirectChat = await DirectChat.create({ creatorId: creator, @@ -95,7 +95,7 @@ export const createTestDirectChatwithUsers = async ( export const createDirectChatMessage = async ( senderId: string, receiverId: string, - directChatId: string + directChatId: string, ): Promise => { const directChatMessage = await DirectChatMessage.create({ directChatMessageBelongsTo: directChatId, diff --git a/tests/helpers/donation.ts b/tests/helpers/donation.ts index e74e965dff2..81eedb016cf 100644 --- a/tests/helpers/donation.ts +++ b/tests/helpers/donation.ts @@ -30,7 +30,7 @@ export const createTestDonation = async (): Promise< }; export const createTestDonationsForOrganization = async ( - organization: TestOrganizationType + organization: TestOrganizationType, ): Promise => { const testUser1 = await createTestUser(); const testDonation1 = await Donation.create({ diff --git a/tests/helpers/events.ts b/tests/helpers/events.ts index 53432afa53d..8b04b744b6f 100644 --- a/tests/helpers/events.ts +++ b/tests/helpers/events.ts @@ -40,7 +40,7 @@ export const createTestEvent = async (): Promise< createdEvents: testEvent._id, registeredEvents: testEvent._id, }, - } + }, ); return [testUser, testOrganization, testEvent]; @@ -53,7 +53,7 @@ export const createEventWithRegistrant = async ( userId: string, organizationId: string, allDay: boolean, - recurrance: string + recurrance: string, ): Promise => { const testEvent = await Event.create({ creatorId: userId, @@ -87,7 +87,7 @@ export const createEventWithRegistrant = async ( createdEvents: testEvent._id, registeredEvents: testEvent._id, }, - } + }, ); return testEvent; }; diff --git a/tests/helpers/eventsWithRegistrants.ts b/tests/helpers/eventsWithRegistrants.ts index f3ff4dca312..6700af5c979 100644 --- a/tests/helpers/eventsWithRegistrants.ts +++ b/tests/helpers/eventsWithRegistrants.ts @@ -9,7 +9,7 @@ export type TestEventType = | null; export const createTestEventWithRegistrants = async ( - isAdmin = true + isAdmin = true, ): Promise<[TestUserType, TestOrganizationType, TestEventType]> => { const [testUser, testOrganization] = await createTestUserAndOrganization(); @@ -40,7 +40,7 @@ export const createTestEventWithRegistrants = async ( createdEvents: testEvent._id, registeredEvents: testEvent._id, }, - } + }, ); return [testUser, testOrganization, testEvent]; diff --git a/tests/helpers/feedback.ts b/tests/helpers/feedback.ts index e48123bbd25..e6657e9e677 100644 --- a/tests/helpers/feedback.ts +++ b/tests/helpers/feedback.ts @@ -11,7 +11,7 @@ export type TestFeedbackType = export const createFeedbackWithIDs = async ( eventId: string, - eventAttendeeId: string + eventAttendeeId: string, ): Promise => { const feedback = await Feedback.create({ eventId, @@ -32,7 +32,7 @@ export const createFeedback = async (): Promise< TestOrganizationType, TestEventType, TestCheckInType, - TestFeedbackType + TestFeedbackType, ] > => { const result = await createEventWithCheckedInUser(); diff --git a/tests/helpers/groupChat.ts b/tests/helpers/groupChat.ts index b1db9a4d169..7f24f1d7557 100644 --- a/tests/helpers/groupChat.ts +++ b/tests/helpers/groupChat.ts @@ -39,7 +39,7 @@ export const createTestGroupChatMessage = async (): Promise< TestUserType, TestOrganizationType, TestGroupChatType, - TestGroupChatMessageType + TestGroupChatMessageType, ] > => { const [testUser, testOrganization, testGroupChat] = diff --git a/tests/helpers/membershipRequests.ts b/tests/helpers/membershipRequests.ts index 05a4f4fbf86..a947f51a233 100644 --- a/tests/helpers/membershipRequests.ts +++ b/tests/helpers/membershipRequests.ts @@ -40,7 +40,7 @@ export const createTestMembershipRequest = async (): Promise< adminFor: testOrganization._id, membershipRequests: testMembershipRequest._id, }, - } + }, ); await Organization.updateOne( @@ -51,7 +51,7 @@ export const createTestMembershipRequest = async (): Promise< $push: { membershipRequests: testMembershipRequest._id, }, - } + }, ); return [testUser, testOrganization, testMembershipRequest]; @@ -85,7 +85,7 @@ export const createTestMembershipRequestAsNew = async (): Promise< }, { new: true, - } + }, ); testOrganization = await Organization.findOneAndUpdate( @@ -99,7 +99,7 @@ export const createTestMembershipRequestAsNew = async (): Promise< }, { new: true, - } + }, ); return [testUser, testOrganization, testMembershipRequest]; } else { diff --git a/tests/helpers/posts.ts b/tests/helpers/posts.ts index adf0140fa78..6ad6f23d08f 100644 --- a/tests/helpers/posts.ts +++ b/tests/helpers/posts.ts @@ -14,7 +14,7 @@ export type TestCommentType = | null; export const createTestPost = async ( - pinned = false + pinned = false, ): Promise<[TestUserType, TestOrganizationType, TestPostType]> => { const resultsArray = await createTestUserAndOrganization(); const testUser = resultsArray[0]; @@ -35,7 +35,7 @@ export const createTestPost = async ( $push: { posts: testPost._id, }, - } + }, ); return [testUser, testOrganization, testPost]; @@ -64,7 +64,7 @@ export const createPostwithComment = async (): Promise< likeCount: 1, commentCount: 1, }, - } + }, ); await Comment.updateOne( @@ -78,14 +78,14 @@ export const createPostwithComment = async (): Promise< $inc: { likeCount: 1, }, - } + }, ); return [testUser, testOrganization, testPost, testComment]; }; export const createSinglePostwithComment = async ( userId: string, - organizationId: string + organizationId: string, ): Promise<[TestPostType, TestCommentType]> => { const testPost = await Post.create({ text: `text${nanoid().toLowerCase()}`, @@ -114,7 +114,7 @@ export const createSinglePostwithComment = async ( likeCount: 1, commentCount: 1, }, - } + }, ); return [testPost, testComment]; }; @@ -122,7 +122,7 @@ export const createSinglePostwithComment = async ( export const createTestSinglePost = async ( userId: string, organizationId: string, - pinned = false + pinned = false, ): Promise => { const testPost = await Post.create({ text: `text${nanoid().toLowerCase()}`, diff --git a/tests/helpers/tags.ts b/tests/helpers/tags.ts index ab9a997b8b6..f5852d14f5e 100644 --- a/tests/helpers/tags.ts +++ b/tests/helpers/tags.ts @@ -21,7 +21,7 @@ export const createRootTagWithOrg = async (): Promise< }; export const createRootTagsWithOrg = async ( - numberOfTags = 1 + numberOfTags = 1, ): Promise<[TestUserType, TestOrganizationType, TestUserTagType[]]> => { const [testUser, testOrganization] = await createTestUserAndOrganization(); const tags: TestUserTagType[] = []; @@ -42,7 +42,7 @@ export const createTwoLevelTagsWithOrg = async (): Promise< [ TestUserType, TestOrganizationType, - [TestUserTagType, TestUserTagType, TestUserTagType] + [TestUserTagType, TestUserTagType, TestUserTagType], ] > => { const [testUser, testOrg, testRootTag] = await createRootTagWithOrg(); @@ -66,7 +66,7 @@ export const createTwoLevelTagsWithOrg = async (): Promise< export const createAndAssignUsersToTag = async ( tag: TestUserTagType, - numberOfUsers = 1 + numberOfUsers = 1, ): Promise => { const testUsers: TestUserType[] = []; @@ -83,7 +83,7 @@ export const createAndAssignUsersToTag = async ( }; export const createTagsAndAssignToUser = async ( - numberOfTags = 1 + numberOfTags = 1, ): Promise<[TestUserType, TestOrganizationType, TestUserTagType[]]> => { const [testUser, testOrg, testTag] = await createRootTagWithOrg(); await TagUser.create({ diff --git a/tests/helpers/userAndOrg.ts b/tests/helpers/userAndOrg.ts index d3e7c11f73c..58ebb4d83cf 100644 --- a/tests/helpers/userAndOrg.ts +++ b/tests/helpers/userAndOrg.ts @@ -28,7 +28,7 @@ export const createTestOrganizationWithAdmin = async ( userID: string, isMember = true, isAdmin = true, - userRegistrationRequired = false + userRegistrationRequired = false, ): Promise => { const testOrganization = await Organization.create({ name: `orgName${nanoid().toLowerCase()}`, @@ -50,7 +50,7 @@ export const createTestOrganizationWithAdmin = async ( adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); return testOrganization; @@ -59,21 +59,21 @@ export const createTestOrganizationWithAdmin = async ( export const createTestUserAndOrganization = async ( isMember = true, isAdmin = true, - userRegistrationRequired = false + userRegistrationRequired = false, ): Promise<[TestUserType, TestOrganizationType]> => { const testUser = await createTestUser(); const testOrganization = await createTestOrganizationWithAdmin( testUser?._id, isMember, isAdmin, - userRegistrationRequired + userRegistrationRequired, ); return [testUser, testOrganization]; }; export const createOrganizationwithVisibility = async ( userID: string, - visibleInSearch: boolean + visibleInSearch: boolean, ): Promise => { const testOrganization = await Organization.create({ name: `orgName${nanoid().toLowerCase()}`, @@ -96,7 +96,7 @@ export const createOrganizationwithVisibility = async ( adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); return testOrganization; diff --git a/tests/libraries/dbLogger.spec.ts b/tests/libraries/dbLogger.spec.ts index 1e6727694a2..0348493487f 100644 --- a/tests/libraries/dbLogger.spec.ts +++ b/tests/libraries/dbLogger.spec.ts @@ -83,14 +83,14 @@ describe("Database transaction logging", () => { const spyInfoLog = vi.spyOn(dbLogger as winston.Logger, "info"); const savePreMiddleware = mockPreFunction.mock.calls.find( - (call) => call[0] === "save" + (call) => call[0] === "save", )?.[1]; savePreMiddleware.call(mockDocument, () => { return; }); expect(mockDocument.logInfo).toBeDefined(); const savePostMiddleware = mockPostFunction.mock.calls.find( - (call) => call[0] === "save" + (call) => call[0] === "save", )?.[1]; savePostMiddleware.call(mockDocument); expect(spyInfoLog).toHaveBeenCalledWith("success", mockDocument.logInfo); @@ -104,14 +104,14 @@ describe("Database transaction logging", () => { ]; operations.forEach((operation) => { const preMiddleware = mockPreFunction.mock.calls.find( - (call) => call[0] === operation + (call) => call[0] === operation, )?.[1]; preMiddleware.call(mockQuery, () => { return; }); expect(mockQuery.logInfo).toBeDefined(); const postMiddleware = mockPostFunction.mock.calls.find( - (call) => call[0] === operation + (call) => call[0] === operation, )?.[1]; postMiddleware.call(mockQuery); expect(spyInfoLog).toHaveBeenCalledWith("success", mockQuery.logInfo); diff --git a/tests/libraries/errors/internalServerError.spec.ts b/tests/libraries/errors/internalServerError.spec.ts index 8e02de71a9a..3514e5f8426 100644 --- a/tests/libraries/errors/internalServerError.spec.ts +++ b/tests/libraries/errors/internalServerError.spec.ts @@ -9,7 +9,7 @@ describe("libraries -> errors -> internalServerError", () => { throw new errors.InternalServerError( INTERNAL_SERVER_ERROR.MESSAGE, INTERNAL_SERVER_ERROR.CODE, - INTERNAL_SERVER_ERROR.PARAM + INTERNAL_SERVER_ERROR.PARAM, ); } catch (error: any) { expect(error.errors).toEqual([ diff --git a/tests/libraries/errors/unauthenticatedError.spec.ts b/tests/libraries/errors/unauthenticatedError.spec.ts index d9bfd90d77e..ec0e22cfdcc 100644 --- a/tests/libraries/errors/unauthenticatedError.spec.ts +++ b/tests/libraries/errors/unauthenticatedError.spec.ts @@ -9,7 +9,7 @@ describe("libraries -> errors -> unauthenticatedError", () => { throw new errors.UnauthenticatedError( UNAUTHENTICATED_ERROR.MESSAGE, UNAUTHENTICATED_ERROR.CODE, - UNAUTHENTICATED_ERROR.PARAM + UNAUTHENTICATED_ERROR.PARAM, ); } catch (error: any) { expect(error.errors).toEqual([ diff --git a/tests/libraries/logger.spec.ts b/tests/libraries/logger.spec.ts index 5257531243d..09a78a4639c 100644 --- a/tests/libraries/logger.spec.ts +++ b/tests/libraries/logger.spec.ts @@ -69,14 +69,14 @@ describe("logger functions", () => { undefined, // splat() undefined, // simple() undefined, // timestamp() - undefined // printf() + undefined, // printf() ); } else { expect(format.combine).toHaveBeenCalledWith( undefined, // splat() undefined, // simple() undefined, // timestamp() - undefined // printf() + undefined, // printf() ); } }); diff --git a/tests/libraries/requestContext.spec.ts b/tests/libraries/requestContext.spec.ts index 1b37aaffdbc..6b7f11311b1 100644 --- a/tests/libraries/requestContext.spec.ts +++ b/tests/libraries/requestContext.spec.ts @@ -54,7 +54,7 @@ describe("middleware -> requestContext", () => { middleware()( mockRequest as Request, mockResponse as Response, - nextFunction as NextFunction + nextFunction as NextFunction, ); expect(nextFunction).toBeCalledTimes(1); }); @@ -91,7 +91,7 @@ describe("middleware -> requestContext", () => { translate({}); } catch (error: any) { expect(error.message).toEqual( - "i18n is not initialized, try app.use(i18n.init);" + "i18n is not initialized, try app.use(i18n.init);", ); } }); @@ -101,7 +101,7 @@ describe("middleware -> requestContext", () => { translatePlural({}); } catch (error: any) { expect(error.message).toEqual( - "i18n is not initialized, try app.use(i18n.init);" + "i18n is not initialized, try app.use(i18n.init);", ); } }); diff --git a/tests/libraries/requestTracing.spec.ts b/tests/libraries/requestTracing.spec.ts index 1dab8b79c22..9a094445855 100644 --- a/tests/libraries/requestTracing.spec.ts +++ b/tests/libraries/requestTracing.spec.ts @@ -45,7 +45,7 @@ describe("middleware -> requestContext", () => { }; const resHeaderMethod = ( tracingIdHeaderName: string, - tracingID: string + tracingID: string, ): string => { return requestTracingNamespace.set(tracingIdHeaderName, tracingID); }; @@ -60,7 +60,7 @@ describe("middleware -> requestContext", () => { middleware()( mockRequest as Request, mockResponse as Response, - nextFunction as NextFunction + nextFunction as NextFunction, ); expect(tracingIdHeaderName).toBe("X-Tracing-Id"); expect(nextFunction).toBeCalledTimes(1); diff --git a/tests/middleware/isAuth.spec.ts b/tests/middleware/isAuth.spec.ts index 66e4dccb19e..aaa80a65aab 100644 --- a/tests/middleware/isAuth.spec.ts +++ b/tests/middleware/isAuth.spec.ts @@ -100,7 +100,7 @@ describe("middleware -> isAuth", () => { expect(verifyMocked).toHaveBeenCalledWith( testToken, ACCESS_TOKEN_SECRET as string, - expect.anything() + expect.anything(), ); expect(authData).toEqual(testAuthData); }); @@ -129,7 +129,7 @@ describe("middleware -> isAuth", () => { expect(verifyMocked).toHaveBeenCalledWith( testToken, ACCESS_TOKEN_SECRET as string, - expect.anything() + expect.anything(), ); expect(infoSpy).toBeCalledWith("decoded token is not present"); expect(authData).toEqual(testAuthData); @@ -191,7 +191,7 @@ describe("middleware -> isAuth", () => { expect(verifyMocked).toHaveBeenCalledWith( testToken, ACCESS_TOKEN_SECRET as string, - expect.anything() + expect.anything(), ); expect(authData).toEqual(testAuthData); }); diff --git a/tests/resolvers/ActionItem/category.spec.ts b/tests/resolvers/ActionItem/category.spec.ts index d034f89468b..e7b87bdb943 100644 --- a/tests/resolvers/ActionItem/category.spec.ts +++ b/tests/resolvers/ActionItem/category.spec.ts @@ -28,7 +28,7 @@ describe("resolvers -> ActionItem -> actionItemCategory", () => { const actionItemCategoryPayload = await actionItemCategoryResolver?.( parent, {}, - {} + {}, ); const actionItemCategoryObject = await ActionItemCategory.findOne({ diff --git a/tests/resolvers/ActionItem/event.spec.ts b/tests/resolvers/ActionItem/event.spec.ts index f93397e5a51..1dabeb75084 100644 --- a/tests/resolvers/ActionItem/event.spec.ts +++ b/tests/resolvers/ActionItem/event.spec.ts @@ -51,7 +51,7 @@ describe("resolvers -> ActionItem -> event", () => { }, { new: true, - } + }, ); const parent = updatedTestActionItem?.toObject(); @@ -59,7 +59,7 @@ describe("resolvers -> ActionItem -> event", () => { const eventByPayload = await eventResolver?.( parent as InterfaceActionItem, {}, - {} + {}, ); expect(eventByPayload?._id).toEqual(updatedTestActionItem?.eventId); diff --git a/tests/resolvers/DirectChatMessage/directChatMessageBelongsTo.spec.ts b/tests/resolvers/DirectChatMessage/directChatMessageBelongsTo.spec.ts index 93d20eb2459..bed2971cc94 100644 --- a/tests/resolvers/DirectChatMessage/directChatMessageBelongsTo.spec.ts +++ b/tests/resolvers/DirectChatMessage/directChatMessageBelongsTo.spec.ts @@ -32,7 +32,7 @@ describe("resolvers -> DirectChatMessage -> directChatMessageBelongsTo", () => { }).lean(); expect(directChatMessageBelongsToPayload).toEqual( - directChatMessageBelongsTo + directChatMessageBelongsTo, ); }); }); diff --git a/tests/resolvers/Event/averageFeedbackScore.test.ts b/tests/resolvers/Event/averageFeedbackScore.test.ts index ed6bdebad33..e02c71c2b18 100644 --- a/tests/resolvers/Event/averageFeedbackScore.test.ts +++ b/tests/resolvers/Event/averageFeedbackScore.test.ts @@ -30,7 +30,7 @@ describe("resolvers -> Event -> averageFeedbackScore", () => { const averageFeedbackScorePayload = await averageFeedbackScoreResolver?.( parent, {}, - {} + {}, ); expect(averageFeedbackScorePayload).toEqual(0); @@ -44,7 +44,7 @@ describe("resolvers -> Event -> averageFeedbackScore", () => { const averageFeedbackScorePayload = await averageFeedbackScoreResolver?.( parent, {}, - {} + {}, ); expect(averageFeedbackScorePayload).toEqual(3); diff --git a/tests/resolvers/GroupChat/creator.spec.ts b/tests/resolvers/GroupChat/creator.spec.ts index 22e5cd4f0f5..5184e618d44 100644 --- a/tests/resolvers/GroupChat/creator.spec.ts +++ b/tests/resolvers/GroupChat/creator.spec.ts @@ -28,7 +28,7 @@ describe("resolvers -> GroupChat -> creator", () => { const creatorPayload = await creatorResolver?.( parent ?? ({} as InterfaceGroupChat), {}, - {} + {}, ); const creator = await User.findOne({ diff --git a/tests/resolvers/Mutation/acceptAdmin.spec.ts b/tests/resolvers/Mutation/acceptAdmin.spec.ts index c6540c67112..fee1bd04c8b 100644 --- a/tests/resolvers/Mutation/acceptAdmin.spec.ts +++ b/tests/resolvers/Mutation/acceptAdmin.spec.ts @@ -65,7 +65,7 @@ describe("resolvers -> Mutation -> acceptAdmin", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -92,7 +92,7 @@ describe("resolvers -> Mutation -> acceptAdmin", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); } }); @@ -107,7 +107,7 @@ describe("resolvers -> Mutation -> acceptAdmin", () => { userType: "SUPERADMIN", adminApproved: true, }, - } + }, ); const args: MutationAcceptAdminArgs = { @@ -153,7 +153,7 @@ describe("resolvers -> Mutation -> acceptAdmin", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/acceptMembershipRequest.spec.ts b/tests/resolvers/Mutation/acceptMembershipRequest.spec.ts index f7a9612f815..e162680de14 100644 --- a/tests/resolvers/Mutation/acceptMembershipRequest.spec.ts +++ b/tests/resolvers/Mutation/acceptMembershipRequest.spec.ts @@ -71,10 +71,10 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { await acceptMembershipRequestResolver?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenCalledWith( - MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE + MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${MEMBERSHIP_REQUEST_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -94,7 +94,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationAcceptMembershipRequestArgs = { @@ -112,7 +112,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -133,7 +133,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { organization: testOrganization?._id, user: Types.ObjectId().toString(), }, - } + }, ); const args: MutationAcceptMembershipRequestArgs = { @@ -151,7 +151,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -174,7 +174,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { $set: { user: testUser?.id, }, - } + }, ); await Organization.updateOne( @@ -185,7 +185,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { $set: { admins: [], }, - } + }, ); const args: MutationAcceptMembershipRequestArgs = { @@ -203,7 +203,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } }); @@ -225,7 +225,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { admins: testUser?._id, members: testUser?._id, }, - } + }, ); const args: MutationAcceptMembershipRequestArgs = { @@ -243,7 +243,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_ALREADY_MEMBER_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_ALREADY_MEMBER_ERROR.MESSAGE}` + `Translated ${USER_ALREADY_MEMBER_ERROR.MESSAGE}`, ); } }); @@ -257,7 +257,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { $set: { members: [], }, - } + }, ); const args: MutationAcceptMembershipRequestArgs = { @@ -273,7 +273,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { await acceptMembershipRequestResolver?.({}, args, context); expect(acceptMembershipRequestPayload?._id).toEqual( - testMembershipRequest?._id + testMembershipRequest?._id, ); const updatedTestOrganization = await Organization.findOne({ @@ -286,7 +286,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { expect.objectContaining({ members: expect.arrayContaining([testUser?._id]), membershipRequests: expect.arrayContaining([]), - }) + }), ); const updatedTestUser = await User.findOne({ @@ -299,7 +299,7 @@ describe("resolvers -> Mutation -> acceptMembershipRequest", () => { expect.objectContaining({ joinedOrganizations: expect.arrayContaining([testOrganization?._id]), membershipRequests: expect.arrayContaining([]), - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/addEventAttendee.spec.ts b/tests/resolvers/Mutation/addEventAttendee.spec.ts index 8c6aeb256e3..1881c9e1bfb 100644 --- a/tests/resolvers/Mutation/addEventAttendee.spec.ts +++ b/tests/resolvers/Mutation/addEventAttendee.spec.ts @@ -54,7 +54,7 @@ describe("resolvers -> Mutation -> addEventAttendee", () => { await addEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -84,7 +84,7 @@ describe("resolvers -> Mutation -> addEventAttendee", () => { await addEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); } @@ -114,7 +114,7 @@ describe("resolvers -> Mutation -> addEventAttendee", () => { await addEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); } @@ -144,7 +144,7 @@ describe("resolvers -> Mutation -> addEventAttendee", () => { await addEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -202,10 +202,10 @@ describe("resolvers -> Mutation -> addEventAttendee", () => { await addEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_ALREADY_REGISTERED_FOR_EVENT.MESSAGE}` + `Translated ${USER_ALREADY_REGISTERED_FOR_EVENT.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - USER_ALREADY_REGISTERED_FOR_EVENT.MESSAGE + USER_ALREADY_REGISTERED_FOR_EVENT.MESSAGE, ); } }); diff --git a/tests/resolvers/Mutation/addFeedback.spec.ts b/tests/resolvers/Mutation/addFeedback.spec.ts index 8382cfa2071..77163a46c23 100644 --- a/tests/resolvers/Mutation/addFeedback.spec.ts +++ b/tests/resolvers/Mutation/addFeedback.spec.ts @@ -58,7 +58,7 @@ describe("resolvers -> Query -> addFeedback", () => { await addFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); } @@ -91,10 +91,10 @@ describe("resolvers -> Query -> addFeedback", () => { await addFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}` + `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - USER_NOT_REGISTERED_FOR_EVENT.MESSAGE + USER_NOT_REGISTERED_FOR_EVENT.MESSAGE, ); } }); @@ -131,7 +131,7 @@ describe("resolvers -> Query -> addFeedback", () => { await addFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_CHECKED_IN.MESSAGE}` + `Translated ${USER_NOT_CHECKED_IN.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_CHECKED_IN.MESSAGE); } @@ -197,7 +197,7 @@ describe("resolvers -> Query -> addFeedback", () => { await addFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${FEEDBACK_ALREADY_SUBMITTED.MESSAGE}` + `Translated ${FEEDBACK_ALREADY_SUBMITTED.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(FEEDBACK_ALREADY_SUBMITTED.MESSAGE); } diff --git a/tests/resolvers/Mutation/addLanguageTranslation.spec.ts b/tests/resolvers/Mutation/addLanguageTranslation.spec.ts index bc0233f2880..9dd9dab5193 100644 --- a/tests/resolvers/Mutation/addLanguageTranslation.spec.ts +++ b/tests/resolvers/Mutation/addLanguageTranslation.spec.ts @@ -61,7 +61,7 @@ describe("resolvers -> Mutation -> addLanguageTranslation", () => { for language with en === args.data.en_value`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { const args: MutationAddLanguageTranslationArgs = testArgs[1]; @@ -93,7 +93,7 @@ describe("resolvers -> Mutation -> addLanguageTranslation", () => { value: testArgs[2].data.translation_value, }), ]), - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/addOrganizationCustomField.spec.ts b/tests/resolvers/Mutation/addOrganizationCustomField.spec.ts index dc89dcba371..785cba79417 100644 --- a/tests/resolvers/Mutation/addOrganizationCustomField.spec.ts +++ b/tests/resolvers/Mutation/addOrganizationCustomField.spec.ts @@ -45,13 +45,13 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { const newCustomField = await addOrganizationCustomField?.( {}, args, - context + context, ); expect(newCustomField?.name).toBe("testName"); expect(newCustomField?.type).toBe("testType"); expect(newCustomField?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); }); @@ -77,7 +77,7 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -101,7 +101,7 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(CUSTOM_FIELD_NAME_MISSING.MESSAGE); expect(error.message).toEqual( - `Translated ${CUSTOM_FIELD_NAME_MISSING.MESSAGE}` + `Translated ${CUSTOM_FIELD_NAME_MISSING.MESSAGE}`, ); } }); @@ -125,7 +125,7 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(CUSTOM_FIELD_TYPE_MISSING.MESSAGE); expect(error.message).toEqual( - `Translated ${CUSTOM_FIELD_TYPE_MISSING.MESSAGE}` + `Translated ${CUSTOM_FIELD_TYPE_MISSING.MESSAGE}`, ); } }); @@ -153,7 +153,7 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -175,10 +175,10 @@ describe("resolvers => Mutation => addOrganizationCustomField", () => { await addOrganizationCustomField?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/addOrganizationImage.spec.ts b/tests/resolvers/Mutation/addOrganizationImage.spec.ts index 0a955ed3683..92a9b446396 100644 --- a/tests/resolvers/Mutation/addOrganizationImage.spec.ts +++ b/tests/resolvers/Mutation/addOrganizationImage.spec.ts @@ -82,10 +82,10 @@ describe("resolvers -> Mutation -> addOrganizationImage", () => { $set: { image: testImagePath, }, - } + }, ); vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const args: MutationAddOrganizationImageArgs = { organizationId: testOrganization?.id, @@ -97,7 +97,7 @@ describe("resolvers -> Mutation -> addOrganizationImage", () => { const addOrganizationImagePayload = await addOrganizationImageResolver?.( {}, args, - context + context, ); const updatedTestOrganization = await Organization.findOne({ _id: testOrganization?._id, diff --git a/tests/resolvers/Mutation/addUserCustomData.spec.ts b/tests/resolvers/Mutation/addUserCustomData.spec.ts index 5f8e2cd2452..a3d483a4127 100644 --- a/tests/resolvers/Mutation/addUserCustomData.spec.ts +++ b/tests/resolvers/Mutation/addUserCustomData.spec.ts @@ -42,7 +42,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { expect(customDataDoc?.values).toHaveProperty(args.dataName, args.dataValue); expect(customDataDoc?.userId.toString()).toBe(testUser?._id.toString()); expect(customDataDoc?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); expect(customDataDoc?.userId.toString()).toBe(testUser?._id.toString()); }); @@ -67,7 +67,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -91,10 +91,10 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { await addUserCustomData?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/addUserImage.spec.ts b/tests/resolvers/Mutation/addUserImage.spec.ts index 889dee44833..e27cce6e401 100644 --- a/tests/resolvers/Mutation/addUserImage.spec.ts +++ b/tests/resolvers/Mutation/addUserImage.spec.ts @@ -65,7 +65,7 @@ describe("resolvers -> Mutation -> addUserImage", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -75,7 +75,7 @@ describe("resolvers -> Mutation -> addUserImage", () => { file: "newImageFile.png", }; vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const context = { userId: testUser?._id, @@ -84,7 +84,7 @@ describe("resolvers -> Mutation -> addUserImage", () => { const addUserImagePayload = await addUserImageResolverUserImage?.( {}, args, - context + context, ); expect(addUserImagePayload).toEqual({ diff --git a/tests/resolvers/Mutation/addUserToGroupChat.spec.ts b/tests/resolvers/Mutation/addUserToGroupChat.spec.ts index 11bf2753aad..46e1c7f3c08 100644 --- a/tests/resolvers/Mutation/addUserToGroupChat.spec.ts +++ b/tests/resolvers/Mutation/addUserToGroupChat.spec.ts @@ -92,7 +92,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationAddUserToGroupChatArgs = { @@ -132,7 +132,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { $set: { organization: testOrganization?._id, }, - } + }, ); await Organization.updateOne( @@ -143,7 +143,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { $set: { admins: [], }, - } + }, ); const args: MutationAddUserToGroupChatArgs = { @@ -160,7 +160,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { await addUserToGroupChat?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); @@ -184,7 +184,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -245,7 +245,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { $set: { users: [], }, - } + }, ); const args: MutationAddUserToGroupChatArgs = { @@ -262,7 +262,7 @@ describe("resolvers -> Mutation -> addUserToGroupChat", () => { const addUserToGroupChatPayload = await addUserToGroupChat?.( {}, args, - context + context, ); expect(addUserToGroupChatPayload?._id).toEqual(testGroupChat?._id); expect(addUserToGroupChatPayload?.users).toEqual([testUser?._id]); diff --git a/tests/resolvers/Mutation/adminRemoveEvent.spec.ts b/tests/resolvers/Mutation/adminRemoveEvent.spec.ts index 863f77d0edc..baaec2a5a3a 100644 --- a/tests/resolvers/Mutation/adminRemoveEvent.spec.ts +++ b/tests/resolvers/Mutation/adminRemoveEvent.spec.ts @@ -36,7 +36,7 @@ beforeAll(async () => { testEvent = resultsArray[2]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -48,7 +48,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { it(`throws NotFoundError if no event exists with _id === args.id`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationAdminRemoveEventArgs = { @@ -79,7 +79,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { }, { new: true, - } + }, ); const args: MutationAdminRemoveEventArgs = { @@ -109,7 +109,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { }, { new: true, - } + }, ); if (updatedEvent !== null) { @@ -143,7 +143,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -194,7 +194,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { const adminRemoveEventPayload = await adminRemoveEventResolver?.( {}, args, - context + context, ); expect(adminRemoveEventPayload).toEqual({ @@ -213,7 +213,7 @@ describe("resolvers -> Mutation -> adminRemoveEvent", () => { createdEvents: expect.arrayContaining([]), eventAdmin: expect.arrayContaining([]), registeredEvents: expect.arrayContaining([]), - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/adminRemoveGroup.spec.ts b/tests/resolvers/Mutation/adminRemoveGroup.spec.ts index 6e6610c06d1..69ecb10ec8d 100644 --- a/tests/resolvers/Mutation/adminRemoveGroup.spec.ts +++ b/tests/resolvers/Mutation/adminRemoveGroup.spec.ts @@ -35,7 +35,7 @@ beforeAll(async () => { testGroupChat = resultsArray[2]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -71,7 +71,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationAdminRemoveGroupArgs = { @@ -98,7 +98,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { $set: { organization: testOrganization?._id, }, - } + }, ); const args: MutationAdminRemoveGroupArgs = { @@ -126,7 +126,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { $set: { organization: testOrganization?._id, }, - } + }, ); const updatedOrganization = await Organization.findOneAndUpdate( @@ -140,7 +140,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { }, { new: true, - } + }, ); cacheOrganizations([updatedOrganization!]); @@ -171,7 +171,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { }, { new: true, - } + }, ); cacheOrganizations([updatedOrganization!]); @@ -187,7 +187,7 @@ describe("resolvers -> Mutation -> adminRemoveGroup", () => { const adminRemoveGroupPayload = await adminRemoveGroupResolver?.( {}, args, - context + context, ); expect(adminRemoveGroupPayload).toEqual({ diff --git a/tests/resolvers/Mutation/assignUserTag.spec.ts b/tests/resolvers/Mutation/assignUserTag.spec.ts index f9eda54f3f5..8b0e9e870e9 100644 --- a/tests/resolvers/Mutation/assignUserTag.spec.ts +++ b/tests/resolvers/Mutation/assignUserTag.spec.ts @@ -73,7 +73,7 @@ describe("resolvers -> Mutation -> assignUserTag", () => { await assignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -103,7 +103,7 @@ describe("resolvers -> Mutation -> assignUserTag", () => { await assignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -165,10 +165,10 @@ describe("resolvers -> Mutation -> assignUserTag", () => { await assignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -199,10 +199,10 @@ describe("resolvers -> Mutation -> assignUserTag", () => { await assignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE}` + `Translated ${USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - `${USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE}` + `${USER_DOES_NOT_BELONG_TO_TAGS_ORGANIZATION.MESSAGE}`, ); } }); @@ -258,7 +258,7 @@ describe("resolvers -> Mutation -> assignUserTag", () => { await assignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_ALREADY_HAS_TAG.MESSAGE}` + `Translated ${USER_ALREADY_HAS_TAG.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(`${USER_ALREADY_HAS_TAG.MESSAGE}`); } diff --git a/tests/resolvers/Mutation/blockPluginCreationBySuperadmin.spec.ts b/tests/resolvers/Mutation/blockPluginCreationBySuperadmin.spec.ts index 903ca5a3c4b..7056c29f462 100644 --- a/tests/resolvers/Mutation/blockPluginCreationBySuperadmin.spec.ts +++ b/tests/resolvers/Mutation/blockPluginCreationBySuperadmin.spec.ts @@ -30,7 +30,7 @@ beforeAll(async () => { testUser = await createTestUser(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -88,7 +88,7 @@ describe("resolvers -> Mutation -> blockPluginCreationBySuperadmin", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); } }); @@ -101,7 +101,7 @@ describe("resolvers -> Mutation -> blockPluginCreationBySuperadmin", () => { }, { userType: "SUPERADMIN", - } + }, ); const args: MutationBlockPluginCreationBySuperadminArgs = { diff --git a/tests/resolvers/Mutation/blockUser.spec.ts b/tests/resolvers/Mutation/blockUser.spec.ts index d63096aa1d0..374960dca1f 100644 --- a/tests/resolvers/Mutation/blockUser.spec.ts +++ b/tests/resolvers/Mutation/blockUser.spec.ts @@ -61,11 +61,11 @@ beforeAll(async () => { createdOrganizations: [testOrganization._id], joinedOrganizations: [testOrganization._id], }, - } + }, ); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -115,7 +115,7 @@ describe("resolvers -> Mutation -> blockUser", () => { it(`throws member not found error if user with args.userId is not a member of the organization`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { @@ -140,7 +140,7 @@ describe("resolvers -> Mutation -> blockUser", () => { it(`throws cannot block self error if context.userId === args.userId`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> blockUser", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -213,7 +213,7 @@ describe("resolvers -> Mutation -> blockUser", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -228,7 +228,7 @@ describe("resolvers -> Mutation -> blockUser", () => { $push: { adminFor: testOrganization?._id, }, - } + }, ); const args: MutationBlockUserArgs = { @@ -259,7 +259,7 @@ describe("resolvers -> Mutation -> blockUser", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { diff --git a/tests/resolvers/Mutation/cancelMembershipRequest.spec.ts b/tests/resolvers/Mutation/cancelMembershipRequest.spec.ts index 8f99fb3d0a0..ccbcc6c44d5 100644 --- a/tests/resolvers/Mutation/cancelMembershipRequest.spec.ts +++ b/tests/resolvers/Mutation/cancelMembershipRequest.spec.ts @@ -34,7 +34,7 @@ beforeAll(async () => { testMembershipRequest = resultsArray[2]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -70,7 +70,7 @@ describe("resolvers -> Mutation -> cancelMembershipRequest", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationCancelMembershipRequestArgs = { @@ -97,7 +97,7 @@ describe("resolvers -> Mutation -> cancelMembershipRequest", () => { $set: { organization: testOrganization?._id, }, - } + }, ); const args: MutationCancelMembershipRequestArgs = { @@ -125,7 +125,7 @@ describe("resolvers -> Mutation -> cancelMembershipRequest", () => { $set: { user: Types.ObjectId().toString(), }, - } + }, ); const args: MutationCancelMembershipRequestArgs = { @@ -151,7 +151,7 @@ describe("resolvers -> Mutation -> cancelMembershipRequest", () => { $set: { user: testUser?._id, }, - } + }, ); const args: MutationCancelMembershipRequestArgs = { @@ -166,7 +166,7 @@ describe("resolvers -> Mutation -> cancelMembershipRequest", () => { await cancelMembershipRequestResolver?.({}, args, context); expect(cancelMembershipRequestPayload).toEqual( - testMembershipRequest?.toObject() + testMembershipRequest?.toObject(), ); const testUpdatedUser = await User.findOne({ diff --git a/tests/resolvers/Mutation/checkIn.spec.ts b/tests/resolvers/Mutation/checkIn.spec.ts index 373c16dd764..d2cd9ab755f 100644 --- a/tests/resolvers/Mutation/checkIn.spec.ts +++ b/tests/resolvers/Mutation/checkIn.spec.ts @@ -56,7 +56,7 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -86,7 +86,7 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); } @@ -116,7 +116,7 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); } @@ -146,7 +146,7 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -176,10 +176,10 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}` + `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - USER_NOT_REGISTERED_FOR_EVENT.MESSAGE + USER_NOT_REGISTERED_FOR_EVENT.MESSAGE, ); } }); @@ -239,7 +239,7 @@ describe("resolvers -> Mutation -> checkIn", () => { await checkInResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_ALREADY_CHECKED_IN.MESSAGE}` + `Translated ${USER_ALREADY_CHECKED_IN.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_ALREADY_CHECKED_IN.MESSAGE); } diff --git a/tests/resolvers/Mutation/createActionItem.spec.ts b/tests/resolvers/Mutation/createActionItem.spec.ts index c2b0ec22fcf..a1f85cb226f 100644 --- a/tests/resolvers/Mutation/createActionItem.spec.ts +++ b/tests/resolvers/Mutation/createActionItem.spec.ts @@ -37,7 +37,7 @@ beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); randomUser = await createTestUser(); @@ -52,7 +52,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); [testUser, testOrganization, testCategory] = await createTestCategory(); @@ -111,7 +111,7 @@ describe("resolvers -> Mutation -> createActionItem", () => { await createActionItemResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE + ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE, ); } }); @@ -161,7 +161,7 @@ describe("resolvers -> Mutation -> createActionItem", () => { }, { $push: { joinedOrganizations: testOrganization?._id }, - } + }, ); try { @@ -218,13 +218,13 @@ describe("resolvers -> Mutation -> createActionItem", () => { const createActionItemPayload = await createActionItemResolver?.( {}, args, - context + context, ); expect(createActionItemPayload).toEqual( expect.objectContaining({ actionItemCategoryId: testCategory?._id, - }) + }), ); }); @@ -243,13 +243,13 @@ describe("resolvers -> Mutation -> createActionItem", () => { const createActionItemPayload = await createActionItemResolver?.( {}, args, - context + context, ); expect(createActionItemPayload).toEqual( expect.objectContaining({ actionItemCategoryId: testCategory?._id, - }) + }), ); }); @@ -268,13 +268,13 @@ describe("resolvers -> Mutation -> createActionItem", () => { const createActionItemPayload = await createActionItemResolver?.( {}, args, - context + context, ); expect(createActionItemPayload).toEqual( expect.objectContaining({ actionItemCategoryId: testCategory?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createActionItemCategory.spec.ts b/tests/resolvers/Mutation/createActionItemCategory.spec.ts index f7963414722..8f126a2d90f 100644 --- a/tests/resolvers/Mutation/createActionItemCategory.spec.ts +++ b/tests/resolvers/Mutation/createActionItemCategory.spec.ts @@ -31,7 +31,7 @@ beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); randomUser = await createTestUser(); @@ -108,14 +108,14 @@ describe("resolvers -> Mutation -> createCategory", () => { const createCategoryPayload = await createActionItemCategoryResolver?.( {}, args, - context + context, ); expect(createCategoryPayload).toEqual( expect.objectContaining({ organizationId: testOrganization?._id, name: "Default", - }) + }), ); }); @@ -129,7 +129,7 @@ describe("resolvers -> Mutation -> createCategory", () => { }, { new: true, - } + }, ); const args: MutationCreateActionItemCategoryArgs = { @@ -144,14 +144,14 @@ describe("resolvers -> Mutation -> createCategory", () => { const createCategoryPayload = await createActionItemCategoryResolver?.( {}, args, - context + context, ); expect(createCategoryPayload).toEqual( expect.objectContaining({ organizationId: testOrganization?._id, name: "Default2", - }) + }), ); }); @@ -169,7 +169,7 @@ describe("resolvers -> Mutation -> createCategory", () => { await createActionItemCategoryResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - ACTION_ITEM_CATEGORY_ALREADY_EXISTS.MESSAGE + ACTION_ITEM_CATEGORY_ALREADY_EXISTS.MESSAGE, ); } }); diff --git a/tests/resolvers/Mutation/createAdmin.spec.ts b/tests/resolvers/Mutation/createAdmin.spec.ts index 7b2706ca4c2..86945a3d386 100644 --- a/tests/resolvers/Mutation/createAdmin.spec.ts +++ b/tests/resolvers/Mutation/createAdmin.spec.ts @@ -32,7 +32,7 @@ beforeAll(async () => { testOrganization = resultsArray[1]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -70,7 +70,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { creatorId: Types.ObjectId().toString(), }, - } + }, ); const args: MutationCreateAdminArgs = { @@ -100,7 +100,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { creatorId: testUser?._id, }, - } + }, ); await User.updateOne( @@ -111,7 +111,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { userType: "SUPERADMIN", }, - } + }, ); const args: MutationCreateAdminArgs = { @@ -148,7 +148,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { await createAdminResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - ORGANIZATION_MEMBER_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_MEMBER_NOT_FOUND_ERROR.MESSAGE, ); } }); @@ -167,7 +167,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -203,7 +203,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { diff --git a/tests/resolvers/Mutation/createAdvertisement.spec.ts b/tests/resolvers/Mutation/createAdvertisement.spec.ts index 58b0c9de7e9..3e6df4a6b34 100644 --- a/tests/resolvers/Mutation/createAdvertisement.spec.ts +++ b/tests/resolvers/Mutation/createAdvertisement.spec.ts @@ -71,14 +71,14 @@ describe("resolvers -> Mutation -> createAdvertisement", () => { const createdAdvertisementPayload = await createAdvertisementResolver?.( {}, args, - context + context, ); expect(createdAdvertisementPayload).toHaveProperty("name", "myad"); expect(createdAdvertisementPayload).toHaveProperty( "link", - "https://www.example.com" + "https://www.example.com", ); expect(createdAdvertisementPayload).toHaveProperty("type", "POPUP"); diff --git a/tests/resolvers/Mutation/createComment.spec.ts b/tests/resolvers/Mutation/createComment.spec.ts index 5539fcb675a..a079f765b8d 100644 --- a/tests/resolvers/Mutation/createComment.spec.ts +++ b/tests/resolvers/Mutation/createComment.spec.ts @@ -23,7 +23,7 @@ beforeAll(async () => { testPost = resultsArray[2]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -66,13 +66,13 @@ describe("resolvers -> Mutation -> createComment", () => { const createCommentPayload = await createCommentResolver?.( {}, args, - context + context, ); expect(createCommentPayload).toEqual( expect.objectContaining({ text: "text", - }) + }), ); const testUpdatedPost = await Post.findOne({ @@ -83,7 +83,7 @@ describe("resolvers -> Mutation -> createComment", () => { expect(testUpdatedPost?.commentCount).toEqual(1); expect(createCommentPayload?.postId.toString()).toEqual( - testPost?._id.toString() + testPost?._id.toString(), ); }); }); diff --git a/tests/resolvers/Mutation/createDirectChat.spec.ts b/tests/resolvers/Mutation/createDirectChat.spec.ts index d1e5a796d3f..4adb1882cb7 100644 --- a/tests/resolvers/Mutation/createDirectChat.spec.ts +++ b/tests/resolvers/Mutation/createDirectChat.spec.ts @@ -115,7 +115,7 @@ describe("resolvers -> Mutation -> createDirectChat", () => { const createDirectChatPayload = await createDirectChatResolver?.( {}, args, - context + context, ); expect(createDirectChatPayload).toEqual( @@ -123,7 +123,7 @@ describe("resolvers -> Mutation -> createDirectChat", () => { creatorId: testUser?._id, users: [testUser?._id], organization: testOrganization?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createDonation.spec.ts b/tests/resolvers/Mutation/createDonation.spec.ts index d3e759dc605..987edaf2849 100644 --- a/tests/resolvers/Mutation/createDonation.spec.ts +++ b/tests/resolvers/Mutation/createDonation.spec.ts @@ -47,7 +47,7 @@ describe("resolvers -> Mutation -> createDonation", () => { orgId: testOrganization?._id, payPalId: "payPalId", userId: testUser?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createEvent.spec.ts b/tests/resolvers/Mutation/createEvent.spec.ts index 9a20ba98848..b782ed5e4dd 100644 --- a/tests/resolvers/Mutation/createEvent.spec.ts +++ b/tests/resolvers/Mutation/createEvent.spec.ts @@ -49,11 +49,11 @@ beforeAll(async () => { $push: { adminFor: testOrganization?._id, }, - } + }, ); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -159,7 +159,7 @@ describe("resolvers -> Mutation -> createEvent", () => { } catch (error: unknown) { if (error instanceof UnauthorizedError) { expect(error.message).toEqual( - ORGANIZATION_NOT_AUTHORIZED_ERROR.MESSAGE + ORGANIZATION_NOT_AUTHORIZED_ERROR.MESSAGE, ); } else { fail(`Expected UnauthorizedError, but got ${error}`); @@ -177,7 +177,7 @@ describe("resolvers -> Mutation -> createEvent", () => { createdOrganizations: testOrganization?._id, joinedOrganizations: testOrganization?._id, }, - } + }, ); const args: MutationCreateEventArgs = { @@ -223,7 +223,7 @@ describe("resolvers -> Mutation -> createEvent", () => { creatorId: testUser?._id, admins: expect.arrayContaining([testUser?._id]), organization: testOrganization?._id, - }) + }), ); const recurringEvents = await Event.find({ @@ -252,7 +252,7 @@ describe("resolvers -> Mutation -> createEvent", () => { eventAdmin: expect.arrayContaining([createEventPayload?._id]), createdEvents: expect.arrayContaining([createEventPayload?._id]), registeredEvents: expect.arrayContaining([createEventPayload?._id]), - }) + }), ); }); @@ -266,7 +266,7 @@ describe("resolvers -> Mutation -> createEvent", () => { createdOrganizations: testOrganization?._id, joinedOrganizations: testOrganization?._id, }, - } + }, ); const args: MutationCreateEventArgs = { @@ -312,7 +312,7 @@ describe("resolvers -> Mutation -> createEvent", () => { creatorId: testUser?._id, admins: expect.arrayContaining([testUser?._id]), organization: testOrganization?._id, - }) + }), ); const recurringEvents = await Event.find({ @@ -342,7 +342,7 @@ describe("resolvers -> Mutation -> createEvent", () => { eventAdmin: expect.arrayContaining([createEventPayload?._id]), createdEvents: expect.arrayContaining([createEventPayload?._id]), registeredEvents: expect.arrayContaining([createEventPayload?._id]), - }) + }), ); }); @@ -356,7 +356,7 @@ describe("resolvers -> Mutation -> createEvent", () => { createdOrganizations: testOrganization?._id, joinedOrganizations: testOrganization?._id, }, - } + }, ); const args: MutationCreateEventArgs = { @@ -402,7 +402,7 @@ describe("resolvers -> Mutation -> createEvent", () => { creatorId: testUser?._id, admins: expect.arrayContaining([testUser?._id]), organization: testOrganization?._id, - }) + }), ); const recurringEvents = await Event.find({ @@ -431,7 +431,7 @@ describe("resolvers -> Mutation -> createEvent", () => { eventAdmin: expect.arrayContaining([createEventPayload?._id]), createdEvents: expect.arrayContaining([createEventPayload?._id]), registeredEvents: expect.arrayContaining([createEventPayload?._id]), - }) + }), ); }); @@ -496,7 +496,7 @@ describe("Check for validation conditions", () => { it(`throws String Length Validation error if title is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateEventArgs = { @@ -532,7 +532,7 @@ describe("Check for validation conditions", () => { } catch (error: unknown) { if (error instanceof InputValidationError) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ); } else { fail(`Expected LengthValidationError, but got ${error}`); @@ -542,7 +542,7 @@ describe("Check for validation conditions", () => { it(`throws String Length Validation error if description is greater than 500 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateEventArgs = { @@ -578,7 +578,7 @@ describe("Check for validation conditions", () => { } catch (error: unknown) { if (error instanceof InputValidationError) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ); } else { fail(`Expected LengthValidationError, but got ${error}`); @@ -588,7 +588,7 @@ describe("Check for validation conditions", () => { it(`throws String Length Validation error if location is greater than 50 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateEventArgs = { @@ -623,7 +623,7 @@ describe("Check for validation conditions", () => { } catch (error: unknown) { if (error instanceof InputValidationError) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location`, ); } else { fail(`Expected LengthValidationError, but got ${error}`); @@ -633,7 +633,7 @@ describe("Check for validation conditions", () => { it(`throws Date Validation error if start date is greater than end date`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateEventArgs = { @@ -668,7 +668,7 @@ describe("Check for validation conditions", () => { } catch (error: unknown) { if (error instanceof InputValidationError) { expect(error.message).toEqual( - `start date must be earlier than end date` + `start date must be earlier than end date`, ); } else { fail(`Expected DateValidationError, but got ${error}`); diff --git a/tests/resolvers/Mutation/createGroupChat.spec.ts b/tests/resolvers/Mutation/createGroupChat.spec.ts index 8b22d629a83..92efcfb5a59 100644 --- a/tests/resolvers/Mutation/createGroupChat.spec.ts +++ b/tests/resolvers/Mutation/createGroupChat.spec.ts @@ -28,7 +28,7 @@ beforeAll(async () => { testOrganization = resultsArray[1]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -93,7 +93,7 @@ describe("resolvers -> Mutation -> createGroupChat", () => { const createGroupChatPayload = await createGroupChatResolver?.( {}, args, - context + context, ); expect(createGroupChatPayload).toEqual( @@ -102,7 +102,7 @@ describe("resolvers -> Mutation -> createGroupChat", () => { creatorId: testUser?._id, users: [testUser?._id], organization: testOrganization?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createMember.spec.ts b/tests/resolvers/Mutation/createMember.spec.ts index f217990fa0a..2cd9e1c7a4f 100644 --- a/tests/resolvers/Mutation/createMember.spec.ts +++ b/tests/resolvers/Mutation/createMember.spec.ts @@ -30,7 +30,7 @@ beforeAll(async () => { testOrganization = resultsArray[1]; const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); @@ -49,7 +49,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { creatorId: Types.ObjectId().toString(), }, - } + }, ); const args: MutationCreateMemberArgs = { @@ -79,7 +79,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { creatorId: testUser?._id, }, - } + }, ); await User.updateOne( @@ -90,7 +90,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $set: { userType: "SUPERADMIN", }, - } + }, ); const args: MutationCreateMemberArgs = { @@ -140,7 +140,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { $push: { members: testUser?._id, }, - } + }, ); const args: MutationCreateMemberArgs = { @@ -168,7 +168,7 @@ describe("resolvers -> Mutation -> createAdmin", () => { .lean(); const updatedOrganizationCheck = updatedTestOrganization?.members.some( - (member) => member.equals(testUser?._id) + (member) => member.equals(testUser?._id), ); expect(updatedOrganizationCheck).toBe(true); diff --git a/tests/resolvers/Mutation/createMessageChat.spec.ts b/tests/resolvers/Mutation/createMessageChat.spec.ts index e1033a68802..886852db238 100644 --- a/tests/resolvers/Mutation/createMessageChat.spec.ts +++ b/tests/resolvers/Mutation/createMessageChat.spec.ts @@ -78,7 +78,7 @@ describe("resolvers -> Mutation -> createMessageChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -96,7 +96,7 @@ describe("resolvers -> Mutation -> createMessageChat", () => { _action: "CHAT_CHANNEL", _payload: { directMessageChat: InterfaceMessageChat; - } + }, ): { _action: string; _payload: { directMessageChat: InterfaceMessageChat }; @@ -116,7 +116,7 @@ describe("resolvers -> Mutation -> createMessageChat", () => { const createMessageChatPayload = await createMessageChatResolver?.( {}, args, - context + context, ); expect(createMessageChatPayload).toEqual( @@ -125,7 +125,7 @@ describe("resolvers -> Mutation -> createMessageChat", () => { receiver: testUsers[1]._id, message: "message", languageBarrier: false, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createOrganization.spec.ts b/tests/resolvers/Mutation/createOrganization.spec.ts index 03e107065db..c3664ae546c 100644 --- a/tests/resolvers/Mutation/createOrganization.spec.ts +++ b/tests/resolvers/Mutation/createOrganization.spec.ts @@ -81,7 +81,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { await createOrganization?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE + USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE, ); expect(error.message).toEqual(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); } @@ -96,7 +96,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { // ); vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); await User.findOneAndUpdate( @@ -108,7 +108,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { adminApproved: true, userType: "SUPERADMIN", }, - } + }, ); const args: MutationCreateOrganizationArgs = { @@ -138,7 +138,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { const createOrganizationPayload = await createOrganizationResolver?.( {}, args, - context + context, ); expect(createOrganizationPayload).toEqual( expect.objectContaining({ @@ -161,7 +161,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { admins: [testUser?._id], members: [testUser?._id], image: "imagePath", - }) + }), ); expect(createOrganizationPayload?.image).toEqual("imagePath"); @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { joinedOrganizations: [createOrganizationPayload?._id], createdOrganizations: [createOrganizationPayload?._id], adminFor: [createOrganizationPayload?._id], - }) + }), ); const defaultCategory = await ActionItemCategory.findOne({ @@ -188,7 +188,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { organizationId: createOrganizationPayload?._id, name: "Default", isDisabled: false, - }) + }), ); }); it(`creates the organization without image and returns it`, async () => { @@ -196,7 +196,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { async (newImagePath: any, imageAlreadyInDbPath: any) => ({ newImagePath, imageAlreadyInDbPath, - }) + }), ); const args: MutationCreateOrganizationArgs = { data: { @@ -225,7 +225,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { const createOrganizationPayload = await createOrganizationResolver?.( {}, args, - context + context, ); expect(createOrganizationPayload).toEqual( expect.objectContaining({ @@ -247,7 +247,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { creatorId: testUser?._id, admins: [testUser?._id], members: [testUser?._id], - }) + }), ); expect(createOrganizationPayload?.image).toBe(null); }); @@ -255,7 +255,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { it(`throws String Length Validation error if name is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateOrganizationArgs = { @@ -285,14 +285,14 @@ describe("resolvers -> Mutation -> createOrganization", () => { await createOrganizationResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in name`, ); } }); it(`throws String Length Validation error if description is greater than 500 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationCreateOrganizationArgs = { @@ -323,14 +323,14 @@ describe("resolvers -> Mutation -> createOrganization", () => { await createOrganizationResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ); } }); it("throws Address Validation Error for an invalid address", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const invalidAddress = { @@ -400,14 +400,14 @@ describe("resolvers -> Mutation -> createOrganization", () => { } } else { console.error( - "Error: createOrganizationResolver is undefined in the test suite" + "Error: createOrganizationResolver is undefined in the test suite", ); } }); it("throws Address Validation Error for missing address", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const missingAddress = {}; // No address field in the data @@ -436,7 +436,7 @@ describe("resolvers -> Mutation -> createOrganization", () => { } } else { console.error( - "Error: createOrganizationResolver is undefined in the test suite" + "Error: createOrganizationResolver is undefined in the test suite", ); } }); diff --git a/tests/resolvers/Mutation/createPlugin.spec.ts b/tests/resolvers/Mutation/createPlugin.spec.ts index a6ab977a8ab..a7219b4fc78 100644 --- a/tests/resolvers/Mutation/createPlugin.spec.ts +++ b/tests/resolvers/Mutation/createPlugin.spec.ts @@ -25,7 +25,7 @@ describe("resolvers -> Mutation -> createPlugin", () => { expect(createPluginPayload).toEqual( expect.objectContaining({ ...data, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/createPost.spec.ts b/tests/resolvers/Mutation/createPost.spec.ts index c3a69250b4c..2461b83cc35 100644 --- a/tests/resolvers/Mutation/createPost.spec.ts +++ b/tests/resolvers/Mutation/createPost.spec.ts @@ -87,7 +87,7 @@ describe("resolvers -> Mutation -> createPost", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -120,7 +120,7 @@ describe("resolvers -> Mutation -> createPost", () => { } catch (error: any) { expect(spy).toBeCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -154,7 +154,7 @@ describe("resolvers -> Mutation -> createPost", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_TO_PIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_TO_PIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_TO_PIN.MESSAGE}`, ); } }); @@ -162,7 +162,7 @@ describe("resolvers -> Mutation -> createPost", () => { it(`pinned post should be successfully added to the organization`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationCreatePostArgs = { @@ -189,7 +189,7 @@ describe("resolvers -> Mutation -> createPost", () => { text: "New Post Text", videoUrl: null, // Update the expected value to match the received value title: "New Post Title", - }) + }), ); const updatedTestOrg = await Organization.findOne({ @@ -199,7 +199,7 @@ describe("resolvers -> Mutation -> createPost", () => { expect( updatedTestOrg?.pinnedPosts .map((id) => id.toString()) - .includes(createdPost?._id.toString()) + .includes(createdPost?._id.toString()), ).toBeTruthy(); }); @@ -231,7 +231,7 @@ describe("resolvers -> Mutation -> createPost", () => { creatorId: testUser?._id, organization: testOrganization?._id, imageUrl: null, - }) + }), ); }); @@ -255,19 +255,19 @@ describe("resolvers -> Mutation -> createPost", () => { vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( () => { throw new Error("Unsupported file type."); - } + }, ); // Ensure that an error is thrown when createPostResolverImage is called await expect( - createPostResolverImage?.({}, args, context) + createPostResolverImage?.({}, args, context), ).rejects.toThrowError("Unsupported file type."); }); it(`throws String Length Validation error if title is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationCreatePostArgs = { @@ -293,14 +293,14 @@ describe("resolvers -> Mutation -> createPost", () => { await createPostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ); } }); it(`throws String Length Validation error if text is greater than 500 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationCreatePostArgs = { @@ -325,7 +325,7 @@ describe("resolvers -> Mutation -> createPost", () => { await createPostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information`, ); } }); @@ -333,7 +333,7 @@ describe("resolvers -> Mutation -> createPost", () => { it("throws error if title is provided and post is not pinned", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationCreatePostArgs = { @@ -355,7 +355,7 @@ describe("resolvers -> Mutation -> createPost", () => { await createPostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Post needs to be pinned inorder to add a title` + `Post needs to be pinned inorder to add a title`, ); } }); @@ -363,7 +363,7 @@ describe("resolvers -> Mutation -> createPost", () => { it("throws error if title is not provided and post is pinned", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationCreatePostArgs = { diff --git a/tests/resolvers/Mutation/createSampleOrganization.spec.ts b/tests/resolvers/Mutation/createSampleOrganization.spec.ts index c378e5465cd..65c0ac57f95 100644 --- a/tests/resolvers/Mutation/createSampleOrganization.spec.ts +++ b/tests/resolvers/Mutation/createSampleOrganization.spec.ts @@ -39,7 +39,7 @@ describe("createSampleOrganization resolver", async () => { it("should NOT throw error when user is ADMIN", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const ORGANIZATION_ID = faker.database.mongodbObjectId(); @@ -53,7 +53,7 @@ describe("createSampleOrganization resolver", async () => { const adminResult = await createSampleOrganization!( parent, args, - adminContext + adminContext, ); expect(adminResult).toBe(true); await SampleData.deleteMany({}); @@ -62,7 +62,7 @@ describe("createSampleOrganization resolver", async () => { it("should NOT throw error when user is SUPERADMIN", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const ORGANIZATION_ID = faker.database.mongodbObjectId(); @@ -76,7 +76,7 @@ describe("createSampleOrganization resolver", async () => { const adminResult = await createSampleOrganization!( parent, args, - adminContext + adminContext, ); expect(adminResult).toBe(true); await SampleData.deleteMany({}); @@ -85,7 +85,7 @@ describe("createSampleOrganization resolver", async () => { it("should throw unauthorized error for non-admins", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const ORGANIZATION_ID = faker.database.mongodbObjectId(); @@ -106,7 +106,7 @@ describe("createSampleOrganization resolver", async () => { it("should throw error when the sample organization already exist", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const ORGANIZATION_ID = faker.database.mongodbObjectId(); @@ -120,7 +120,7 @@ describe("createSampleOrganization resolver", async () => { const adminResult = await createSampleOrganization!( parent, args, - adminContext + adminContext, ); expect(adminResult).toBe(true); @@ -137,7 +137,7 @@ describe("createSampleOrganization resolver", async () => { it("should throw error when the current user doesn't exist", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const args = {}; diff --git a/tests/resolvers/Mutation/createUserTag.spec.ts b/tests/resolvers/Mutation/createUserTag.spec.ts index a72ea942e76..e82d5ddfea5 100644 --- a/tests/resolvers/Mutation/createUserTag.spec.ts +++ b/tests/resolvers/Mutation/createUserTag.spec.ts @@ -82,7 +82,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -113,7 +113,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -175,7 +175,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(INCORRECT_TAG_INPUT.MESSAGE); expect(error.message).toEqual( - `Translated ${INCORRECT_TAG_INPUT.MESSAGE}` + `Translated ${INCORRECT_TAG_INPUT.MESSAGE}`, ); } }); @@ -207,7 +207,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_TO_CREATE_TAG.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_TO_CREATE_TAG.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_TO_CREATE_TAG.MESSAGE}`, ); } }); @@ -245,7 +245,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { it(`tag should be successfully added`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationCreateUserTagArgs = { @@ -271,7 +271,7 @@ describe("resolvers -> Mutation -> createUserTag", () => { organizationId: testOrganization?._id, name: "TestUserTag", parentTagId: testTag?._id, - }) + }), ); const createdTagExists = await OrganizationTagUser.exists({ diff --git a/tests/resolvers/Mutation/deleteAdvertisementById.spec.ts b/tests/resolvers/Mutation/deleteAdvertisementById.spec.ts index df2e83b806a..52c70e2e1b2 100644 --- a/tests/resolvers/Mutation/deleteAdvertisementById.spec.ts +++ b/tests/resolvers/Mutation/deleteAdvertisementById.spec.ts @@ -45,7 +45,7 @@ describe("resolvers -> Mutation -> deleteAdvertiementById", () => { const deleteDonationByIdPayload = await deleteAdvertisementById?.( {}, args, - {} + {}, ); expect(deleteDonationByIdPayload).toEqual({ @@ -61,7 +61,7 @@ describe("resolvers -> Mutation -> deleteAdvertiementById", () => { const deleteDonationByIdPayload = await deleteAdvertisementById?.( {}, args, - {} + {}, ); expect(deleteDonationByIdPayload).toEqual({ diff --git a/tests/resolvers/Mutation/deleteDonationById.spec.ts b/tests/resolvers/Mutation/deleteDonationById.spec.ts index 5fa09389b0c..f83879d2090 100644 --- a/tests/resolvers/Mutation/deleteDonationById.spec.ts +++ b/tests/resolvers/Mutation/deleteDonationById.spec.ts @@ -44,7 +44,7 @@ describe("resolvers -> Mutation -> deleteDonationById", () => { const deleteDonationByIdPayload = await deleteDonationByIdResolver?.( {}, args, - {} + {}, ); expect(deleteDonationByIdPayload).toEqual({ @@ -60,7 +60,7 @@ describe("resolvers -> Mutation -> deleteDonationById", () => { const deleteDonationByIdPayload = await deleteDonationByIdResolver?.( {}, args, - {} + {}, ); expect(deleteDonationByIdPayload).toEqual({ diff --git a/tests/resolvers/Mutation/forgotPassword.spec.ts b/tests/resolvers/Mutation/forgotPassword.spec.ts index cec1bc0475d..192a83a7145 100644 --- a/tests/resolvers/Mutation/forgotPassword.spec.ts +++ b/tests/resolvers/Mutation/forgotPassword.spec.ts @@ -34,7 +34,7 @@ describe("resolvers -> Mutation -> forgotPassword", () => { process.env.NODE_ENV!, { expiresIn: 99999999, - } + }, ); const args: MutationForgotPasswordArgs = { @@ -64,7 +64,7 @@ describe("resolvers -> Mutation -> forgotPassword", () => { process.env.NODE_ENV ?? "", { expiresIn: 99999999, - } + }, ); const args: MutationForgotPasswordArgs = { diff --git a/tests/resolvers/Mutation/getAdvertisement.spec.ts b/tests/resolvers/Mutation/getAdvertisement.spec.ts index 7c5c920090a..eaf1cf51981 100644 --- a/tests/resolvers/Mutation/getAdvertisement.spec.ts +++ b/tests/resolvers/Mutation/getAdvertisement.spec.ts @@ -73,7 +73,7 @@ describe("resolvers -> Mutation -> getAdvertisement", () => { const createdAdvertisementPayload = await createAdvertisementResolver?.( {}, args, - context + context, ); const { getAdvertisements: getAdvertisementResolver } = await import( @@ -82,7 +82,7 @@ describe("resolvers -> Mutation -> getAdvertisement", () => { const getAdvertisementPayload = await getAdvertisementResolver?.( {}, args, - context + context, ); if (getAdvertisementPayload) { const lastIndex = getAdvertisementPayload.length - 1; @@ -90,12 +90,12 @@ describe("resolvers -> Mutation -> getAdvertisement", () => { expect(getAdvertisementPayload[lastIndex]).toHaveProperty( "link", - "https://www.example.com" + "https://www.example.com", ); expect(getAdvertisementPayload[lastIndex]).toHaveProperty( "type", - "POPUP" + "POPUP", ); } }); diff --git a/tests/resolvers/Mutation/joinPublicOrganization.spec.ts b/tests/resolvers/Mutation/joinPublicOrganization.spec.ts index b06929e6b80..9db4edf4207 100644 --- a/tests/resolvers/Mutation/joinPublicOrganization.spec.ts +++ b/tests/resolvers/Mutation/joinPublicOrganization.spec.ts @@ -112,7 +112,7 @@ describe("resolvers -> Mutation -> joinPublicOrganization", () => { }, { new: true, - } + }, ); await cacheOrganizations([updatedOrganizaiton!]); @@ -171,7 +171,7 @@ describe("resolvers -> Mutation -> joinPublicOrganization", () => { }, { new: true, - } + }, ); await cacheOrganizations([updatedOrganizaiton!]); diff --git a/tests/resolvers/Mutation/leaveOrganization.spec.ts b/tests/resolvers/Mutation/leaveOrganization.spec.ts index bf2ba6e0ba7..0ff28cd801d 100644 --- a/tests/resolvers/Mutation/leaveOrganization.spec.ts +++ b/tests/resolvers/Mutation/leaveOrganization.spec.ts @@ -116,7 +116,7 @@ describe("resolvers -> Mutation -> leaveOrganization", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -154,7 +154,7 @@ describe("resolvers -> Mutation -> leaveOrganization", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -172,7 +172,7 @@ describe("resolvers -> Mutation -> leaveOrganization", () => { const leaveOrganizationPayload = await leaveOrganizationResolver?.( {}, args, - context + context, ); const updatedTestUser = await User.findOne({ diff --git a/tests/resolvers/Mutation/likeComment.spec.ts b/tests/resolvers/Mutation/likeComment.spec.ts index 8e7d2d42c99..39b234e9219 100644 --- a/tests/resolvers/Mutation/likeComment.spec.ts +++ b/tests/resolvers/Mutation/likeComment.spec.ts @@ -49,7 +49,7 @@ beforeAll(async () => { $inc: { commentCount: 1, }, - } + }, ); }); diff --git a/tests/resolvers/Mutation/login.spec.ts b/tests/resolvers/Mutation/login.spec.ts index a7917d651ce..2342ac4c947 100644 --- a/tests/resolvers/Mutation/login.spec.ts +++ b/tests/resolvers/Mutation/login.spec.ts @@ -38,7 +38,7 @@ beforeAll(async () => { $set: { password: hashedTestPassword, }, - } + }, ); const testOrganization = temp[1]; const testMembershipRequest = await MembershipRequest.create({ @@ -54,7 +54,7 @@ beforeAll(async () => { $push: { membershipRequests: testMembershipRequest._id, }, - } + }, ); await Organization.updateOne( @@ -65,7 +65,7 @@ beforeAll(async () => { $push: { membershipRequests: testMembershipRequest._id, }, - } + }, ); }); @@ -103,7 +103,7 @@ describe("resolvers -> Mutation -> login", () => { if (error instanceof Error) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } } @@ -174,7 +174,7 @@ email === args.data.email`, async () => { const updatedUser = await User.findOneAndUpdate( { _id: testUser?._id }, { token: newToken, $inc: { tokenVersion: 1 } }, - { new: true } + { new: true }, ); expect(updatedUser).toBeDefined(); @@ -214,7 +214,7 @@ email === args.data.email`, async () => { expect(loginPayload).toEqual( expect.objectContaining({ user: testUser, - }) + }), ); expect(loginPayload?.user).toBeDefined(); expect(typeof loginPayload?.accessToken).toBe("string"); diff --git a/tests/resolvers/Mutation/otp.spec.ts b/tests/resolvers/Mutation/otp.spec.ts index a7ea4c8b7eb..5113556191b 100644 --- a/tests/resolvers/Mutation/otp.spec.ts +++ b/tests/resolvers/Mutation/otp.spec.ts @@ -48,7 +48,7 @@ describe("resolvers -> Mutation -> otp", () => { vi.doMock("../../../src/constants", async () => { const actualConstants: object = await vi.importActual( - "../../../src/constants" + "../../../src/constants", ); return { diff --git a/tests/resolvers/Mutation/refreshToken.spec.ts b/tests/resolvers/Mutation/refreshToken.spec.ts index c6030aa532a..4a0dd407d81 100644 --- a/tests/resolvers/Mutation/refreshToken.spec.ts +++ b/tests/resolvers/Mutation/refreshToken.spec.ts @@ -61,7 +61,7 @@ describe("resolvers -> Mutation -> refreshToken", () => { if (error instanceof Error) { expect(spy).toBeCalledWith(INVALID_REFRESH_TOKEN_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${INVALID_REFRESH_TOKEN_ERROR.MESSAGE}` + `Translated ${INVALID_REFRESH_TOKEN_ERROR.MESSAGE}`, ); } } @@ -92,7 +92,7 @@ describe("resolvers -> Mutation -> refreshToken", () => { if (error instanceof Error) { expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); spy.mockRestore(); @@ -104,7 +104,7 @@ describe("resolvers -> Mutation -> refreshToken", () => { with _id === payload.userId for args.refreshToken`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { await User.updateOne( @@ -115,11 +115,11 @@ describe("resolvers -> Mutation -> refreshToken", () => { $inc: { tokenVersion: 1, }, - } + }, ); refreshToken = await createRefreshToken( - testUser ? testUser.toObject() : ({} as InterfaceUser) + testUser ? testUser.toObject() : ({} as InterfaceUser), ); const args: MutationRefreshTokenArgs = { @@ -153,11 +153,11 @@ describe("resolvers -> Mutation -> refreshToken", () => { $inc: { tokenVersion: 1, }, - } + }, ); refreshToken = await createRefreshToken( - testUser ? testUser.toObject() : ({} as InterfaceUser) + testUser ? testUser.toObject() : ({} as InterfaceUser), ); const args: MutationRefreshTokenArgs = { @@ -173,7 +173,7 @@ describe("resolvers -> Mutation -> refreshToken", () => { if (error instanceof Error) { expect(spy).toBeCalledWith(INVALID_REFRESH_TOKEN_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${INVALID_REFRESH_TOKEN_ERROR.MESSAGE}` + `Translated ${INVALID_REFRESH_TOKEN_ERROR.MESSAGE}`, ); } } @@ -199,7 +199,7 @@ describe("resolvers -> Mutation -> refreshToken", () => { const updatedUser = await User.findOneAndUpdate( { _id: jwtPayload.userId }, { $set: { token: newRefreshToken }, $inc: { tokenVersion: 1 } }, - { new: true } + { new: true }, ); expect(updatedUser).toBeDefined(); @@ -220,11 +220,11 @@ describe("resolvers -> Mutation -> refreshToken", () => { $inc: { tokenVersion: -2, }, - } + }, ); refreshToken = await createRefreshToken( - testUser ? testUser.toObject() : ({} as InterfaceUser) + testUser ? testUser.toObject() : ({} as InterfaceUser), ); const args: MutationRefreshTokenArgs = { diff --git a/tests/resolvers/Mutation/registerForEvent.spec.ts b/tests/resolvers/Mutation/registerForEvent.spec.ts index 4137b1d3c15..c26ac407730 100644 --- a/tests/resolvers/Mutation/registerForEvent.spec.ts +++ b/tests/resolvers/Mutation/registerForEvent.spec.ts @@ -108,7 +108,7 @@ describe("resolvers -> Mutation -> registerForEvent", () => { $set: { registeredEvents: [], }, - } + }, ); const args: MutationRegisterForEventArgs = { @@ -122,7 +122,7 @@ describe("resolvers -> Mutation -> registerForEvent", () => { const registerForEventPayload = await registerForEventResolver?.( {}, args, - context + context, ); const testRegisterForEventPayload = await Event.findOne({ diff --git a/tests/resolvers/Mutation/rejectAdmin.spec.ts b/tests/resolvers/Mutation/rejectAdmin.spec.ts index 9918eb86b66..805d74eaca5 100644 --- a/tests/resolvers/Mutation/rejectAdmin.spec.ts +++ b/tests/resolvers/Mutation/rejectAdmin.spec.ts @@ -62,12 +62,12 @@ describe("resolvers -> Mutation -> rejectAdmin", () => { }, { userType: "USER", - } + }, ); await rejectAdminResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); @@ -113,7 +113,7 @@ describe("resolvers -> Mutation -> rejectAdmin", () => { $set: { userType: "SUPERADMIN", }, - } + }, ); const args: MutationRejectAdminArgs = { diff --git a/tests/resolvers/Mutation/rejectMembershipRequest.spec.ts b/tests/resolvers/Mutation/rejectMembershipRequest.spec.ts index 95f65368427..dd9f647ef14 100644 --- a/tests/resolvers/Mutation/rejectMembershipRequest.spec.ts +++ b/tests/resolvers/Mutation/rejectMembershipRequest.spec.ts @@ -91,7 +91,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationRejectMembershipRequestArgs = { @@ -127,7 +127,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { organization: testOrganization?._id, }, - } + }, ); await MembershipRequest.updateOne( @@ -138,7 +138,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { user: Types.ObjectId().toString(), }, - } + }, ); const args: MutationRejectMembershipRequestArgs = { @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { user: testUser?._id, }, - } + }, ); await Organization.findByIdAndUpdate( @@ -187,7 +187,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { admins: [], }, - } + }, ); await User.findByIdAndUpdate( @@ -198,7 +198,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $set: { userType: "USER", }, - } + }, ); const args: MutationRejectMembershipRequestArgs = { @@ -219,7 +219,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } }); @@ -233,7 +233,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { $push: { admins: testUser?._id, }, - } + }, ); const args: MutationRejectMembershipRequestArgs = { @@ -248,7 +248,7 @@ describe("resolvers -> Mutation -> rejectMembershipRequest", () => { await rejectMembershipRequestResolver?.({}, args, context); expect(rejectMembershipRequestPayload?._id).toEqual( - testMembershipRequest?._id + testMembershipRequest?._id, ); const testUpdatedUser = await User.findOne({ diff --git a/tests/resolvers/Mutation/removeActionItem.spec.ts b/tests/resolvers/Mutation/removeActionItem.spec.ts index 780980096a3..7cfca2858ef 100644 --- a/tests/resolvers/Mutation/removeActionItem.spec.ts +++ b/tests/resolvers/Mutation/removeActionItem.spec.ts @@ -44,7 +44,7 @@ beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); randomUser = await createTestUser(); @@ -132,14 +132,14 @@ describe("resolvers -> Mutation -> removeActionItem", () => { const removedActionItemPayload = await removeActionItemResolver?.( {}, args, - context + context, ); // console.log(removedActionItemPayload); expect(removedActionItemPayload).toEqual( expect.objectContaining({ assigneeId: assignedTestUser?._id, - }) + }), ); }); @@ -159,7 +159,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { }, { new: true, - } + }, ); const args: MutationRemoveActionItemArgs = { @@ -173,13 +173,13 @@ describe("resolvers -> Mutation -> removeActionItem", () => { const removedActionItemPayload = await removeActionItemResolver?.( {}, args, - context + context, ); expect(removedActionItemPayload).toEqual( expect.objectContaining({ assigneeId: randomUser?._id, - }) + }), ); }); @@ -199,7 +199,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { }, { new: true, - } + }, ); try { @@ -233,7 +233,7 @@ describe("resolvers -> Mutation -> removeActionItem", () => { }, { new: true, - } + }, ); const args: MutationRemoveActionItemArgs = { @@ -247,13 +247,13 @@ describe("resolvers -> Mutation -> removeActionItem", () => { const removedActionItemPayload = await removeActionItemResolver?.( {}, args, - context + context, ); expect(removedActionItemPayload).toEqual( expect.objectContaining({ assigneeId: randomUser?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/removeAdmin.spec.ts b/tests/resolvers/Mutation/removeAdmin.spec.ts index b605942cbb7..22e9be876b3 100644 --- a/tests/resolvers/Mutation/removeAdmin.spec.ts +++ b/tests/resolvers/Mutation/removeAdmin.spec.ts @@ -129,7 +129,7 @@ describe("resolvers -> Mutation -> removeAdmin", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -155,7 +155,7 @@ describe("resolvers -> Mutation -> removeAdmin", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_ORGANIZATION_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_ORGANIZATION_ADMIN.MESSAGE}` + `Translated ${USER_NOT_ORGANIZATION_ADMIN.MESSAGE}`, ); } }); @@ -181,7 +181,7 @@ describe("resolvers -> Mutation -> removeAdmin", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -206,10 +206,10 @@ describe("resolvers -> Mutation -> removeAdmin", () => { await removeAdminAdminError?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE + USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE, ); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); } }); @@ -224,7 +224,7 @@ describe("resolvers -> Mutation -> removeAdmin", () => { $set: { creatorId: testUserRemover?._id, }, - } + }, ); await User.updateOne( @@ -236,7 +236,7 @@ describe("resolvers -> Mutation -> removeAdmin", () => { adminApproved: true, userType: "SUPERADMIN", }, - } + }, ); const args: MutationRemoveAdminArgs = { diff --git a/tests/resolvers/Mutation/removeAdvertisement.spec.ts b/tests/resolvers/Mutation/removeAdvertisement.spec.ts index 79a05d8523d..d8e32b790b5 100644 --- a/tests/resolvers/Mutation/removeAdvertisement.spec.ts +++ b/tests/resolvers/Mutation/removeAdvertisement.spec.ts @@ -73,7 +73,7 @@ describe("resolvers -> Mutation -> removeAdvertisement", () => { const createdAdvertisementPayload = await createAdvertisementResolver?.( {}, args, - context + context, ); const createdAdvertisementId = createdAdvertisementPayload?._id || ""; @@ -85,19 +85,19 @@ describe("resolvers -> Mutation -> removeAdvertisement", () => { const removeAdvertisementPayload = await removeAdvertisement?.( {}, { id: createdAdvertisementId }, - context + context, ); expect(removeAdvertisementPayload).toHaveProperty( "_id", - createdAdvertisementId + createdAdvertisementId, ); expect(removeAdvertisementPayload).toHaveProperty("name", "myad"); expect(removeAdvertisementPayload).toHaveProperty( "link", - "https://www.example.com" + "https://www.example.com", ); expect(removeAdvertisementPayload).toHaveProperty("type", "POPUP"); @@ -120,12 +120,12 @@ describe("resolvers -> Mutation -> removeAdvertisement", () => { const removeAdvertisementPayload = await removeAdvertisement?.( {}, { id: "64d1f8cb77a4b51004f824b8" }, - context + context, ); } catch (error: any) { expect(spy).toBeCalledWith(ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/removeComment.spec.ts b/tests/resolvers/Mutation/removeComment.spec.ts index c6b5a216ef9..fea64e64cfc 100644 --- a/tests/resolvers/Mutation/removeComment.spec.ts +++ b/tests/resolvers/Mutation/removeComment.spec.ts @@ -56,7 +56,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); }); @@ -138,7 +138,7 @@ describe("resolvers -> Mutation -> removeComment", () => { }, { new: true, - } + }, ); if (updatedComment !== null) { @@ -154,7 +154,7 @@ describe("resolvers -> Mutation -> removeComment", () => { $pull: { adminFor: testPost?.organization, }, - } + }, ); const args: MutationRemoveCommentArgs = { @@ -189,7 +189,7 @@ describe("resolvers -> Mutation -> removeComment", () => { }, { new: true, - } + }, ); if (updatedComment !== null) { @@ -205,7 +205,7 @@ describe("resolvers -> Mutation -> removeComment", () => { $push: { adminFor: testPost?.organization, }, - } + }, ); const args: MutationRemoveCommentArgs = { @@ -219,7 +219,7 @@ describe("resolvers -> Mutation -> removeComment", () => { const removeCommentPayload = await removeCommentResolver?.( {}, args, - context + context, ); const testUpdatedPost = await Post.findOne({ diff --git a/tests/resolvers/Mutation/removeDirectChat.spec.ts b/tests/resolvers/Mutation/removeDirectChat.spec.ts index 45a59735ebe..a2db86cdf9e 100644 --- a/tests/resolvers/Mutation/removeDirectChat.spec.ts +++ b/tests/resolvers/Mutation/removeDirectChat.spec.ts @@ -61,7 +61,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); }); @@ -98,7 +98,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -126,7 +126,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(CHAT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${CHAT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${CHAT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -151,7 +151,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -173,7 +173,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { await removeDirectChatResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); @@ -192,7 +192,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -214,7 +214,7 @@ describe("resolvers -> Mutation -> removeDirectChat", () => { const removeDirectChatPayload = await removeDirectChatResolver?.( {}, args, - context + context, ); expect(removeDirectChatPayload).toEqual(testDirectChat?.toObject()); diff --git a/tests/resolvers/Mutation/removeEvent.spec.ts b/tests/resolvers/Mutation/removeEvent.spec.ts index ae83acaa73d..4025de06c68 100644 --- a/tests/resolvers/Mutation/removeEvent.spec.ts +++ b/tests/resolvers/Mutation/removeEvent.spec.ts @@ -107,7 +107,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { $set: { adminFor: [], }, - } + }, ); await Event.updateOne( @@ -118,7 +118,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { $set: { admins: [], }, - } + }, ); const args: MutationRemoveEventArgs = { @@ -149,7 +149,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { $push: { adminFor: testOrganization?._id, }, - } + }, ); const updatedEvent = await Event.findOneAndUpdate( @@ -163,7 +163,7 @@ describe("resolvers -> Mutation -> removeEvent", () => { }, { new: true, - } + }, ); if (updatedEvent !== null) { diff --git a/tests/resolvers/Mutation/removeEventAttendee.spec.ts b/tests/resolvers/Mutation/removeEventAttendee.spec.ts index 1ed20abac60..11fe27a55d5 100644 --- a/tests/resolvers/Mutation/removeEventAttendee.spec.ts +++ b/tests/resolvers/Mutation/removeEventAttendee.spec.ts @@ -54,7 +54,7 @@ describe("resolvers -> Mutation -> removeEventAttendee", () => { await removeEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -84,7 +84,7 @@ describe("resolvers -> Mutation -> removeEventAttendee", () => { await removeEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); } @@ -114,7 +114,7 @@ describe("resolvers -> Mutation -> removeEventAttendee", () => { await removeEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); } @@ -144,7 +144,7 @@ describe("resolvers -> Mutation -> removeEventAttendee", () => { await removeEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -174,10 +174,10 @@ describe("resolvers -> Mutation -> removeEventAttendee", () => { await removeEventAttendeeResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}` + `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - USER_NOT_REGISTERED_FOR_EVENT.MESSAGE + USER_NOT_REGISTERED_FOR_EVENT.MESSAGE, ); } }); diff --git a/tests/resolvers/Mutation/removeGroupChat.spec.ts b/tests/resolvers/Mutation/removeGroupChat.spec.ts index 0848afb4f1a..0e5f04b5208 100644 --- a/tests/resolvers/Mutation/removeGroupChat.spec.ts +++ b/tests/resolvers/Mutation/removeGroupChat.spec.ts @@ -50,7 +50,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); }); @@ -87,7 +87,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(CHAT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${CHAT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${CHAT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -108,7 +108,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { $set: { organization: Types.ObjectId().toString(), }, - } + }, ); const args: MutationRemoveGroupChatArgs = { @@ -127,7 +127,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -149,7 +149,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { $set: { organization: testOrganization?._id, }, - } + }, ); const updatedOrganization = await Organization.findOneAndUpdate( @@ -163,7 +163,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -186,7 +186,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } }); @@ -204,7 +204,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -226,7 +226,7 @@ describe("resolvers -> Mutation -> removeGroupChat", () => { const removeGroupChatPayload = await removeGroupChatResolver?.( {}, args, - context + context, ); expect(removeGroupChatPayload).toEqual({ diff --git a/tests/resolvers/Mutation/removeMember.spec.ts b/tests/resolvers/Mutation/removeMember.spec.ts index 08a2aa6f4c5..393ec52a779 100644 --- a/tests/resolvers/Mutation/removeMember.spec.ts +++ b/tests/resolvers/Mutation/removeMember.spec.ts @@ -67,7 +67,7 @@ beforeAll(async () => { adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); await User.updateOne( @@ -79,7 +79,7 @@ beforeAll(async () => { adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); await User.updateOne( @@ -90,7 +90,7 @@ beforeAll(async () => { $push: { joinedOrganizations: testOrganization._id, }, - } + }, ); await User.updateOne( @@ -104,7 +104,7 @@ beforeAll(async () => { joinedOrganizations: testOrganization._id, }, }, - } + }, ); }); @@ -172,7 +172,7 @@ describe("resolvers -> Mutation -> removeMember", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } }); @@ -202,7 +202,7 @@ describe("resolvers -> Mutation -> removeMember", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -231,7 +231,7 @@ describe("resolvers -> Mutation -> removeMember", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(MEMBER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${MEMBER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${MEMBER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -287,7 +287,7 @@ describe("resolvers -> Mutation -> removeMember", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ADMIN_REMOVING_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${ADMIN_REMOVING_ADMIN.MESSAGE}` + `Translated ${ADMIN_REMOVING_ADMIN.MESSAGE}`, ); } }); @@ -316,7 +316,7 @@ describe("resolvers -> Mutation -> removeMember", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ADMIN_REMOVING_CREATOR.MESSAGE); expect(error.message).toEqual( - `Translated ${ADMIN_REMOVING_CREATOR.MESSAGE}` + `Translated ${ADMIN_REMOVING_CREATOR.MESSAGE}`, ); } }); @@ -340,7 +340,7 @@ describe("resolvers -> Mutation -> removeMember", () => { const updatedOrganization = await removeMemberResolverRemoveAdminError?.( {}, args, - context + context, ); const removedUser = await User.findOne({ @@ -349,7 +349,7 @@ describe("resolvers -> Mutation -> removeMember", () => { expect(updatedOrganization?.members).not.toContain(testUsers[2]?._id); expect(removedUser?.joinedOrganizations).not.toContain( - testOrganization?._id + testOrganization?._id, ); }); }); diff --git a/tests/resolvers/Mutation/removeOrganization.spec.ts b/tests/resolvers/Mutation/removeOrganization.spec.ts index 32e27e4cfe5..cb5e2ce8b25 100644 --- a/tests/resolvers/Mutation/removeOrganization.spec.ts +++ b/tests/resolvers/Mutation/removeOrganization.spec.ts @@ -86,7 +86,7 @@ beforeAll(async () => { joinedOrganizations: [testOrganization._id], organizationsBlockedBy: [testOrganization._id], }, - } + }, ); await User.updateOne( @@ -97,7 +97,7 @@ beforeAll(async () => { $set: { joinedOrganizations: [testOrganization._id], }, - } + }, ); const testMembershipRequest = await MembershipRequest.create({ @@ -113,7 +113,7 @@ beforeAll(async () => { $push: { membershipRequests: testMembershipRequest._id, }, - } + }, ); testPost = await Post.create({ @@ -144,7 +144,7 @@ beforeAll(async () => { membershipRequests: testMembershipRequest._id, posts: testPost._id, }, - } + }, ); testComment = await Comment.create({ @@ -161,7 +161,7 @@ beforeAll(async () => { $inc: { commentCount: 1, }, - } + }, ); }); @@ -198,7 +198,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -226,7 +226,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -250,7 +250,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -272,7 +272,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); } }); @@ -289,7 +289,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { }, { new: true, - } + }, ); if (updatedOrganization !== null) { @@ -305,7 +305,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { adminApproved: true, userType: "SUPERADMIN", }, - } + }, ); const args: MutationRemoveOrganizationArgs = { @@ -319,7 +319,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { const removeOrganizationPayload = await removeOrganizationResolver?.( {}, args, - context + context, ); const updatedTestUser = await User.findOne({ @@ -421,7 +421,7 @@ describe("resolvers -> Mutation -> removeOrganization", () => { const removeOrganizationPayload = await removeOrganizationResolver?.( {}, args, - context + context, ); expect(removeOrganizationPayload).toEqual({ diff --git a/tests/resolvers/Mutation/removeOrganizationCustomField.spec.ts b/tests/resolvers/Mutation/removeOrganizationCustomField.spec.ts index b40399cc27d..7e14e1d1baf 100644 --- a/tests/resolvers/Mutation/removeOrganizationCustomField.spec.ts +++ b/tests/resolvers/Mutation/removeOrganizationCustomField.spec.ts @@ -52,7 +52,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { }, { userId: testUser?._id, - } + }, ); const initialCustomFields = await OrganizationCustomField.find({ @@ -61,7 +61,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { expect(customField).toBeDefined(); expect(customField?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); const context = { userId: testUser?._id }; @@ -77,7 +77,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { expect(updatedCustomFields).toHaveLength(initialCustomFields.length - 1); const removedCustomField = updatedCustomFields.find( - (field) => field._id.toString() === customField?._id.toString() + (field) => field._id.toString() === customField?._id.toString(), ); expect(removedCustomField).toBeUndefined(); }); @@ -99,7 +99,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { }, { userId: testUser?._id, - } + }, ); const initialCustomFields = await OrganizationCustomField.find({ @@ -108,7 +108,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { expect(customField).toBeDefined(); expect(customField?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); const context = { userId: nonAdmin?._id }; @@ -121,7 +121,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -145,7 +145,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(CUSTOM_FIELD_NOT_FOUND.MESSAGE); expect(error.message).toEqual( - `Translated ${CUSTOM_FIELD_NOT_FOUND.MESSAGE}` + `Translated ${CUSTOM_FIELD_NOT_FOUND.MESSAGE}`, ); } }); @@ -165,12 +165,12 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { }, { userId: testUser?._id, - } + }, ); expect(customField).toBeDefined(); expect(customField?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); const context = { userId: Types.ObjectId().toString() }; @@ -184,7 +184,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -199,12 +199,12 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { }, { userId: testUser?._id, - } + }, ); expect(customField).toBeDefined(); expect(customField?.organizationId.toString()).toBe( - testOrganization?._id.toString() + testOrganization?._id.toString(), ); const context = { userId: testUser?._id }; @@ -217,7 +217,7 @@ describe("resolvers => Mutation => removeOrganizationCustomField", () => { await removeOrganizationCustomField?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/removeOrganizationImage.spec.ts b/tests/resolvers/Mutation/removeOrganizationImage.spec.ts index af6c1b1bd7d..5984af4b21c 100644 --- a/tests/resolvers/Mutation/removeOrganizationImage.spec.ts +++ b/tests/resolvers/Mutation/removeOrganizationImage.spec.ts @@ -68,7 +68,7 @@ beforeAll(async () => { adminFor: [testOrganization._id], joinedOrganizations: [testOrganization._id], }, - } + }, ); }); @@ -106,10 +106,10 @@ describe("resolvers -> Mutation -> removeOrganizationImage", () => { await removeOrganizationImageResolver?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -137,7 +137,7 @@ describe("resolvers -> Mutation -> removeOrganizationImage", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } }); @@ -164,10 +164,10 @@ describe("resolvers -> Mutation -> removeOrganizationImage", () => { await removeOrganizationImageResolver?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_IMAGE_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_IMAGE_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_IMAGE_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_IMAGE_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -198,7 +198,7 @@ describe("resolvers -> Mutation -> removeOrganizationImage", () => { }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { diff --git a/tests/resolvers/Mutation/removePost.spec.ts b/tests/resolvers/Mutation/removePost.spec.ts index 9a2fb19d205..da21878eb20 100644 --- a/tests/resolvers/Mutation/removePost.spec.ts +++ b/tests/resolvers/Mutation/removePost.spec.ts @@ -49,7 +49,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`throws NotFoundError if current user with _id === context.userId does not exist`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { @@ -68,7 +68,7 @@ describe("resolvers -> Mutation -> removePost", () => { await removePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -76,7 +76,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`throws NotFoundError if no post exists with _id === args.id`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { @@ -95,7 +95,7 @@ describe("resolvers -> Mutation -> removePost", () => { await removePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${POST_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${POST_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -103,7 +103,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`throws UnauthorizedError if a non-creator / non-superadmin / non-admin of the org tries to delete the post`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { @@ -122,7 +122,7 @@ describe("resolvers -> Mutation -> removePost", () => { await removePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -130,7 +130,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`deletes the post with no image and video with _id === args.id and returns it`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationRemovePostArgs = { @@ -152,7 +152,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`deletes the post with image with _id === args.id and returns it`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const deletePreviousImage = await import( "../../../src/utilities/encodedImageStorage/deletePreviousImage" @@ -172,7 +172,7 @@ describe("resolvers -> Mutation -> removePost", () => { imageUrl: "images/fakeImagePathimage.png", }, }, - { new: true } + { new: true }, ).lean(); const args: MutationRemovePostArgs = { @@ -195,7 +195,7 @@ describe("resolvers -> Mutation -> removePost", () => { it(`deletes the post with video with _id === args.id and returns it`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const deletePreviousVideo = await import( "../../../src/utilities/encodedVideoStorage/deletePreviousVideo" @@ -215,7 +215,7 @@ describe("resolvers -> Mutation -> removePost", () => { videoUrl: "videos/fakeVideoPathvideo.png", }, }, - { new: true } + { new: true }, ).lean(); const args: MutationRemovePostArgs = { diff --git a/tests/resolvers/Mutation/removeSampleOrganization.spec.ts b/tests/resolvers/Mutation/removeSampleOrganization.spec.ts index cc5030b5971..a575baf84c9 100644 --- a/tests/resolvers/Mutation/removeSampleOrganization.spec.ts +++ b/tests/resolvers/Mutation/removeSampleOrganization.spec.ts @@ -59,7 +59,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should NOT throw error when user is ADMIN", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const admin = generateUserData(ORGANIZATION_ID.toString(), "ADMIN"); @@ -72,7 +72,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => const adminResult = await removeSampleOrganization!( parent, args, - adminContext + adminContext, ); expect(adminResult).toBe(true); }); @@ -80,7 +80,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should not throw error when user is a SUPERADMIN", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const _id = faker.database.mongodbObjectId(); @@ -113,7 +113,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => sampleDocument.save(); const superadmin = generateUserData( organization._id.toString(), - "SUPERADMIN" + "SUPERADMIN", ); (await superadmin).save(); @@ -125,7 +125,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => const superAdminResult = await removeSampleOrganization!( parent, args, - superAdminContext + superAdminContext, ); expect(superAdminResult).toBe(true); @@ -134,7 +134,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should throw unauthorized error for non-admins", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const _id = faker.database.mongodbObjectId(); @@ -181,7 +181,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should throw user not found error when user is non-existent", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const randomUserId = faker.database.mongodbObjectId(); @@ -200,7 +200,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should NOT throw error when user is ADMIN", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const randomOrganizationId = faker.database.mongodbObjectId(); @@ -222,7 +222,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should NOT throw error when organization doesn't exist", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const admin = generateUserData(ORGANIZATION_ID.toString(), "ADMIN"); @@ -244,7 +244,7 @@ describe("Remove Sample Organization Resolver - User Authorization", async () => it("should throw error when the collection name is not a valid one", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const admin = generateUserData(ORGANIZATION_ID.toString(), "ADMIN"); diff --git a/tests/resolvers/Mutation/removeUserCustomData.spec.ts b/tests/resolvers/Mutation/removeUserCustomData.spec.ts index 639b6e01c34..b935571009f 100644 --- a/tests/resolvers/Mutation/removeUserCustomData.spec.ts +++ b/tests/resolvers/Mutation/removeUserCustomData.spec.ts @@ -46,7 +46,7 @@ describe("removeUserCustomData mutation", () => { }, { userId: testUser?._id, - } + }, ); const args = { @@ -59,7 +59,7 @@ describe("removeUserCustomData mutation", () => { const removeCustomData = await removeUserCustomData?.({}, args, context); expect(removeCustomData?.organizationId).toBe( - addedCustomData?.organizationId + addedCustomData?.organizationId, ); expect(removeCustomData?.userId).toBe(addedCustomData?.userId); expect(removeCustomData?.values).toStrictEqual(addedCustomData?.values); @@ -83,7 +83,7 @@ describe("removeUserCustomData mutation", () => { }, { userId: testUser?._id, - } + }, ); const args = { @@ -98,7 +98,7 @@ describe("removeUserCustomData mutation", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -118,7 +118,7 @@ describe("removeUserCustomData mutation", () => { }, { userId: testUser?._id, - } + }, ); const args = { @@ -133,7 +133,7 @@ describe("removeUserCustomData mutation", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -153,7 +153,7 @@ describe("removeUserCustomData mutation", () => { }, { userId: testUser?._id, - } + }, ); const args = { @@ -167,10 +167,10 @@ describe("removeUserCustomData mutation", () => { await removeUserCustomData?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -190,7 +190,7 @@ describe("removeUserCustomData mutation", () => { }, { userId: testUser?._id, - } + }, ); const args = { @@ -204,10 +204,10 @@ describe("removeUserCustomData mutation", () => { await removeUserCustomData?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -229,7 +229,7 @@ describe("removeUserCustomData mutation", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(CUSTOM_DATA_NOT_FOUND.MESSAGE); expect(error.message).toEqual( - `Translated ${CUSTOM_DATA_NOT_FOUND.MESSAGE}` + `Translated ${CUSTOM_DATA_NOT_FOUND.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/removeUserFromGroupChat.spec.ts b/tests/resolvers/Mutation/removeUserFromGroupChat.spec.ts index e127f4ee19a..e30b9e32f00 100644 --- a/tests/resolvers/Mutation/removeUserFromGroupChat.spec.ts +++ b/tests/resolvers/Mutation/removeUserFromGroupChat.spec.ts @@ -78,7 +78,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { $set: { organization: testOrganization?._id, }, - } + }, ); const args: MutationRemoveUserFromGroupChatArgs = { @@ -115,7 +115,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { $push: { admins: testUser?._id, }, - } + }, ); await User.updateOne( @@ -126,7 +126,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { $push: { adminFor: testOrganization?._id, }, - } + }, ); const args: MutationRemoveUserFromGroupChatArgs = { @@ -152,7 +152,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { with _id === args.ChatId and returns the updated groupChat`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); await GroupChat.updateOne( @@ -163,7 +163,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { $push: { users: testUser?._id, }, - } + }, ); const args: MutationRemoveUserFromGroupChatArgs = { @@ -183,7 +183,7 @@ describe("resolvers -> Mutation -> removeUserFromGroupChat", () => { }).lean(); expect(removeUserFromGroupChatPayload).toEqual( - testRemoveUserFromGroupChatPayload + testRemoveUserFromGroupChatPayload, ); }); diff --git a/tests/resolvers/Mutation/removeUserImage.spec.ts b/tests/resolvers/Mutation/removeUserImage.spec.ts index dc31bc992d0..1622a80048e 100644 --- a/tests/resolvers/Mutation/removeUserImage.spec.ts +++ b/tests/resolvers/Mutation/removeUserImage.spec.ts @@ -58,7 +58,7 @@ describe("resolvers -> Mutation -> removeUserImage", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -83,7 +83,7 @@ describe("resolvers -> Mutation -> removeUserImage", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_PROFILE_IMAGE_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_PROFILE_IMAGE_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_PROFILE_IMAGE_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -106,7 +106,7 @@ describe("resolvers -> Mutation -> removeUserImage", () => { $set: { image: testImage, }, - } + }, ); const context = { @@ -120,7 +120,7 @@ describe("resolvers -> Mutation -> removeUserImage", () => { const removeUserImagePayload = await removeUserImageResolver?.( {}, {}, - context + context, ); const updatedTestUser = await User.findOne({ diff --git a/tests/resolvers/Mutation/removeUserTag.spec.ts b/tests/resolvers/Mutation/removeUserTag.spec.ts index 1fa23c86ff7..78104703836 100644 --- a/tests/resolvers/Mutation/removeUserTag.spec.ts +++ b/tests/resolvers/Mutation/removeUserTag.spec.ts @@ -91,7 +91,7 @@ describe("resolvers -> Mutation -> removeUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -145,7 +145,7 @@ describe("resolvers -> Mutation -> removeUserTag", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -153,7 +153,7 @@ describe("resolvers -> Mutation -> removeUserTag", () => { it(`deletes the tag (along with all its child tags) from the OrganizationTagUser model and its corresponding entries from TagUser model`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationRemoveUserTagArgs = { diff --git a/tests/resolvers/Mutation/sendMembershipRequest.spec.ts b/tests/resolvers/Mutation/sendMembershipRequest.spec.ts index 9c109ff1ea0..30493c8e36a 100644 --- a/tests/resolvers/Mutation/sendMembershipRequest.spec.ts +++ b/tests/resolvers/Mutation/sendMembershipRequest.spec.ts @@ -98,7 +98,7 @@ describe("resolvers -> Mutation -> sendMembershipRequest", () => { $set: { membershipRequests: [], }, - } + }, ); await User.updateOne( @@ -109,7 +109,7 @@ describe("resolvers -> Mutation -> sendMembershipRequest", () => { $set: { membershipRequests: [], }, - } + }, ); const args: MutationSendMembershipRequestArgs = { @@ -123,14 +123,14 @@ describe("resolvers -> Mutation -> sendMembershipRequest", () => { const sendMembershipRequestPayload = await sendMembershipRequestResolver?.( {}, args, - context + context, ); expect(sendMembershipRequestPayload).toEqual( expect.objectContaining({ user: testUser?._id, organization: testOrganization?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/sendMessageToDirectChat.spec.ts b/tests/resolvers/Mutation/sendMessageToDirectChat.spec.ts index fa68e9ddd2c..31840853e45 100644 --- a/tests/resolvers/Mutation/sendMessageToDirectChat.spec.ts +++ b/tests/resolvers/Mutation/sendMessageToDirectChat.spec.ts @@ -58,7 +58,7 @@ beforeAll(async () => { adminFor: [testOrganization._id], joinedOrganizations: [testOrganization._id], }, - } + }, ); testDirectChat = await DirectChat.create({ @@ -136,7 +136,7 @@ describe("resolvers -> Mutation -> sendMessageToDirectChat", () => { $push: { users: testUsers[0]?._id, }, - } + }, ); const args: MutationSendMessageToDirectChatArgs = { @@ -149,7 +149,7 @@ describe("resolvers -> Mutation -> sendMessageToDirectChat", () => { _action: "MESSAGE_SENT_TO_DIRECT_CHAT", _payload: { messageSentToDirectChat: InterfaceDirectChatMessage; - } + }, ): { _action: string; _payload: { messageSentToDirectChat: InterfaceDirectChatMessage }; @@ -172,7 +172,7 @@ describe("resolvers -> Mutation -> sendMessageToDirectChat", () => { sender: testUsers[0]?._id, receiver: testUsers[1]?._id, messageContent: "messageContent", - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/sendMessageToGroupChat.spec.ts b/tests/resolvers/Mutation/sendMessageToGroupChat.spec.ts index 79284781c57..77d8ead3cac 100644 --- a/tests/resolvers/Mutation/sendMessageToGroupChat.spec.ts +++ b/tests/resolvers/Mutation/sendMessageToGroupChat.spec.ts @@ -126,7 +126,7 @@ describe("resolvers -> Mutation -> sendMessageToGroupChat", () => { $push: { users: testUser?._id, }, - } + }, ); const args: MutationSendMessageToGroupChatArgs = { @@ -139,7 +139,7 @@ describe("resolvers -> Mutation -> sendMessageToGroupChat", () => { _action: "MESSAGE_SENT_TO_GROUP_CHAT", _payload: { messageSentToGroupChat: InterfaceGroupChatMessage; - } + }, ): { _action: string; _payload: { messageSentToGroupChat: InterfaceGroupChatMessage }; @@ -161,7 +161,7 @@ describe("resolvers -> Mutation -> sendMessageToGroupChat", () => { groupChatMessageBelongsTo: testGroupChat._id, sender: testUser?._id, messageContent: "messageContent", - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/signUp.spec.ts b/tests/resolvers/Mutation/signUp.spec.ts index 68223ee3455..1f78c6d25e9 100644 --- a/tests/resolvers/Mutation/signUp.spec.ts +++ b/tests/resolvers/Mutation/signUp.spec.ts @@ -138,7 +138,7 @@ describe("resolvers -> Mutation -> signUp", () => { }); it(`when uploadImage is called with newFile `, async () => { vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const email = `email${nanoid().toLowerCase()}@gmail.com`; diff --git a/tests/resolvers/Mutation/togglePostPin.spec.ts b/tests/resolvers/Mutation/togglePostPin.spec.ts index 7b42435c299..7a8f592b7de 100644 --- a/tests/resolvers/Mutation/togglePostPin.spec.ts +++ b/tests/resolvers/Mutation/togglePostPin.spec.ts @@ -55,7 +55,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it(`throws NotFoundError if current user with _id === context.userId does not exist`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { @@ -74,7 +74,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { await togglePostPinResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -82,7 +82,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it(`throws NotFoundError if no post exists with _id === args.id`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); try { @@ -101,7 +101,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { await togglePostPinResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${POST_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${POST_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -128,7 +128,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { } catch (error: any) { expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_TO_PIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_TO_PIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_TO_PIN.MESSAGE}`, ); } }); @@ -136,7 +136,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it(`adds a post to the pinnedPosts for an org`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationTogglePostPinArgs = { id: testPost?._id, @@ -160,7 +160,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { }).lean(); const currentPostIsPinned = organization?.pinnedPosts.some((p) => - p.equals(args.id) + p.equals(args.id), ); expect(currentPostIsPinned).toBeTruthy(); @@ -170,7 +170,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it(`removes a post from the pinnedPosts for an org`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationTogglePostPinArgs = { @@ -195,7 +195,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { }).lean(); const currentPostIsPinned = organization?.pinnedPosts.some((p) => - p.equals(args.id) + p.equals(args.id), ); expect(currentPostIsPinned).toBeFalsy(); @@ -205,7 +205,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it("throws error if title is not provided to pin post", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationTogglePostPinArgs = { @@ -229,7 +229,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { it(`throws String Length Validation error if title is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationTogglePostPinArgs = { @@ -249,7 +249,7 @@ describe("resolvers -> Mutation -> togglePostPin", () => { await togglePostPinResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ); } }); diff --git a/tests/resolvers/Mutation/unassignUserTag.spec.ts b/tests/resolvers/Mutation/unassignUserTag.spec.ts index 6fee16804bb..7faa0f244cc 100644 --- a/tests/resolvers/Mutation/unassignUserTag.spec.ts +++ b/tests/resolvers/Mutation/unassignUserTag.spec.ts @@ -72,7 +72,7 @@ describe("resolvers -> Mutation -> unassignUserTag", () => { await unassignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -102,7 +102,7 @@ describe("resolvers -> Mutation -> unassignUserTag", () => { await unassignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -164,10 +164,10 @@ describe("resolvers -> Mutation -> unassignUserTag", () => { await unassignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -197,10 +197,10 @@ describe("resolvers -> Mutation -> unassignUserTag", () => { await unassignUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_DOES_NOT_HAVE_THE_TAG.MESSAGE}` + `Translated ${USER_DOES_NOT_HAVE_THE_TAG.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - `${USER_DOES_NOT_HAVE_THE_TAG.MESSAGE}` + `${USER_DOES_NOT_HAVE_THE_TAG.MESSAGE}`, ); } }); @@ -209,7 +209,7 @@ describe("resolvers -> Mutation -> unassignUserTag", () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); const args: MutationUnassignUserTagArgs = { diff --git a/tests/resolvers/Mutation/unblockUser.spec.ts b/tests/resolvers/Mutation/unblockUser.spec.ts index 09c56a24c05..d73633f3080 100644 --- a/tests/resolvers/Mutation/unblockUser.spec.ts +++ b/tests/resolvers/Mutation/unblockUser.spec.ts @@ -129,7 +129,7 @@ describe("resolvers -> Mutation -> unblockUser", () => { $push: { admins: testUser?._id, }, - } + }, ); await User.updateOne( @@ -140,7 +140,7 @@ describe("resolvers -> Mutation -> unblockUser", () => { $push: { adminFor: testOrganization?._id, }, - } + }, ); const args: MutationUnblockUserArgs = { @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> unblockUser", () => { }, { new: true, - } + }, ).lean(); if (updatedOrganization !== null) { @@ -191,7 +191,7 @@ describe("resolvers -> Mutation -> unblockUser", () => { $push: { organizationsBlockedBy: testOrganization?._id, }, - } + }, ); const args: MutationUnblockUserArgs = { diff --git a/tests/resolvers/Mutation/unlikeComment.spec.ts b/tests/resolvers/Mutation/unlikeComment.spec.ts index 9d5458026ed..51d2f72b24f 100644 --- a/tests/resolvers/Mutation/unlikeComment.spec.ts +++ b/tests/resolvers/Mutation/unlikeComment.spec.ts @@ -42,7 +42,7 @@ beforeAll(async () => { $inc: { commentCount: 1, }, - } + }, ); }); @@ -89,7 +89,7 @@ describe("resolvers -> Mutation -> unlikeComment", () => { const unlikeCommentPayload = await unlikeCommentResolver?.( {}, args, - context + context, ); const testUnlikeCommentPayload = await Comment.findOne({ @@ -112,7 +112,7 @@ describe("resolvers -> Mutation -> unlikeComment", () => { const unlikeCommentPayload = await unlikeCommentResolver?.( {}, args, - context + context, ); const testUnlikeCommentPayload = await Comment.findOne({ diff --git a/tests/resolvers/Mutation/unregisterForEventByUser.spec.ts b/tests/resolvers/Mutation/unregisterForEventByUser.spec.ts index 5d47dbe1a70..67c7ed76d1e 100644 --- a/tests/resolvers/Mutation/unregisterForEventByUser.spec.ts +++ b/tests/resolvers/Mutation/unregisterForEventByUser.spec.ts @@ -65,7 +65,7 @@ describe("resolvers -> Mutation -> unregisterForEventByUser", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -94,7 +94,7 @@ describe("resolvers -> Mutation -> unregisterForEventByUser", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_ALREADY_UNREGISTERED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_ALREADY_UNREGISTERED_ERROR.MESSAGE}` + `Translated ${USER_ALREADY_UNREGISTERED_ERROR.MESSAGE}`, ); } }); @@ -114,7 +114,7 @@ describe("resolvers -> Mutation -> unregisterForEventByUser", () => { $push: { registeredEvents: testEvent?._id, }, - } + }, ); const args: MutationUnregisterForEventByUserArgs = { diff --git a/tests/resolvers/Mutation/updateActionItem.spec.ts b/tests/resolvers/Mutation/updateActionItem.spec.ts index db74533b506..cc307b58d1e 100644 --- a/tests/resolvers/Mutation/updateActionItem.spec.ts +++ b/tests/resolvers/Mutation/updateActionItem.spec.ts @@ -42,7 +42,7 @@ beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); randomUser = await createTestUser(); @@ -180,14 +180,14 @@ describe("resolvers -> Mutation -> updateActionItem", () => { const updatedActionItemPayload = await updateActionItemResolver?.( {}, args, - context + context, ); expect(updatedActionItemPayload).toEqual( expect.objectContaining({ assigneeId: assignedTestUser?._id, actionItemCategoryId: testCategory?._id, - }) + }), ); }); @@ -201,7 +201,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { }, { new: true, - } + }, ); const args: MutationUpdateActionItemArgs = { @@ -218,14 +218,14 @@ describe("resolvers -> Mutation -> updateActionItem", () => { const updatedActionItemPayload = await updateActionItemResolver?.( {}, args, - context + context, ); expect(updatedActionItemPayload).toEqual( expect.objectContaining({ assigneeId: testUser?._id, actionItemCategoryId: testCategory?._id, - }) + }), ); }); @@ -239,7 +239,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { }, { new: true, - } + }, ); await User.updateOne( @@ -248,7 +248,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { }, { $push: { joinedOrganizations: testOrganization?._id }, - } + }, ); try { @@ -279,7 +279,7 @@ describe("resolvers -> Mutation -> updateActionItem", () => { }, { new: true, - } + }, ); const args: MutationUpdateActionItemArgs = { @@ -296,14 +296,14 @@ describe("resolvers -> Mutation -> updateActionItem", () => { const updatedActionItemPayload = await updateActionItemResolver?.( {}, args, - context + context, ); expect(updatedActionItemPayload).toEqual( expect.objectContaining({ actionItemCategoryId: testCategory?._id, assigneeId: testUser?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/updateActionItemCategory.spec.ts b/tests/resolvers/Mutation/updateActionItemCategory.spec.ts index e2718e69cc1..dd90f40c1b4 100644 --- a/tests/resolvers/Mutation/updateActionItemCategory.spec.ts +++ b/tests/resolvers/Mutation/updateActionItemCategory.spec.ts @@ -30,7 +30,7 @@ beforeAll(async () => { MONGOOSE_INSTANCE = await connect(); const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); randomUser = await createTestUser(); @@ -80,7 +80,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { await updateActionItemCategoryResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE + ACTION_ITEM_CATEGORY_NOT_FOUND_ERROR.MESSAGE, ); } }); @@ -121,7 +121,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { const updatedCategory = await updateActionItemCategoryResolver?.( {}, args, - context + context, ); expect(updatedCategory).toEqual( @@ -129,7 +129,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { organizationId: testOrganization?._id, name: "updatedDefault", isDisabled: true, - }) + }), ); }); @@ -143,7 +143,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { }, { new: true, - } + }, ); const args: MutationUpdateActionItemCategoryArgs = { @@ -161,7 +161,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { const updatedCategory = await updateActionItemCategoryResolver?.( {}, args, - context + context, ); expect(updatedCategory).toEqual( @@ -169,7 +169,7 @@ describe("resolvers -> Mutation -> updateActionItemCategoryResolver", () => { organizationId: testOrganization?._id, name: "updatedDefault", isDisabled: false, - }) + }), ); }); }); diff --git a/tests/resolvers/Mutation/updateAdvertisement.spec.ts b/tests/resolvers/Mutation/updateAdvertisement.spec.ts index a0a2f6948fa..327a15ee633 100644 --- a/tests/resolvers/Mutation/updateAdvertisement.spec.ts +++ b/tests/resolvers/Mutation/updateAdvertisement.spec.ts @@ -62,7 +62,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { await updateAdvertisementResolverNotFoundError?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -91,7 +91,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { await updateAdvertisementResolverNotFoundError?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); } @@ -122,10 +122,10 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { await updateAdvertisementResolverNotFoundError?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE + ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ADVERTISEMENT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -156,7 +156,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { const updateAdvertisementPayload = await updateAdvertisementResolver?.( {}, args, - context + context, ); const { advertisement } = updateAdvertisementPayload || {}; @@ -214,7 +214,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(END_DATE_VALIDATION_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${END_DATE_VALIDATION_ERROR.MESSAGE}` + `Translated ${END_DATE_VALIDATION_ERROR.MESSAGE}`, ); } }); @@ -242,7 +242,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(START_DATE_VALIDATION_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${START_DATE_VALIDATION_ERROR.MESSAGE}` + `Translated ${START_DATE_VALIDATION_ERROR.MESSAGE}`, ); } }); @@ -270,7 +270,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(INPUT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${INPUT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${INPUT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -298,7 +298,7 @@ describe("resolvers -> Mutation -> updateAdvertisement", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(FIELD_NON_EMPTY_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${FIELD_NON_EMPTY_ERROR.MESSAGE}` + `Translated ${FIELD_NON_EMPTY_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Mutation/updateEvent.spec.ts b/tests/resolvers/Mutation/updateEvent.spec.ts index 1575968a105..bcd86796a24 100644 --- a/tests/resolvers/Mutation/updateEvent.spec.ts +++ b/tests/resolvers/Mutation/updateEvent.spec.ts @@ -55,7 +55,7 @@ beforeAll(async () => { createdEvents: [testEvent._id], registeredEvents: [testEvent._id], }, - } + }, ); }); @@ -92,7 +92,7 @@ describe("resolvers -> Mutation -> updateEvent", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -120,7 +120,7 @@ describe("resolvers -> Mutation -> updateEvent", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -149,7 +149,7 @@ describe("resolvers -> Mutation -> updateEvent", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -166,7 +166,7 @@ describe("resolvers -> Mutation -> updateEvent", () => { }, { new: true, - } + }, ).lean(); if (updatedEvent !== null) { @@ -181,7 +181,7 @@ describe("resolvers -> Mutation -> updateEvent", () => { $push: { eventAdmin: testEvent?._id, }, - } + }, ); const args: MutationUpdateEventArgs = { @@ -226,7 +226,7 @@ describe("Check for validation conditions", () => { it(`throws String Length Validation error if title is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateEventArgs = { @@ -261,14 +261,14 @@ describe("Check for validation conditions", () => { await updateEventResolverError?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ); } }); it(`throws String Length Validation error if description is greater than 500 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateEventArgs = { @@ -303,14 +303,14 @@ describe("Check for validation conditions", () => { await updateEventResolverError?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in description`, ); } }); it(`throws String Length Validation error if location is greater than 50 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateEventArgs = { @@ -344,14 +344,14 @@ describe("Check for validation conditions", () => { await updateEventResolverError?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 50 characters in location`, ); } }); it(`throws Date Validation error if start date is greater than end date`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateEventArgs = { diff --git a/tests/resolvers/Mutation/updateLanguage.spec.ts b/tests/resolvers/Mutation/updateLanguage.spec.ts index a781c88eee8..1bc6b5b25a3 100644 --- a/tests/resolvers/Mutation/updateLanguage.spec.ts +++ b/tests/resolvers/Mutation/updateLanguage.spec.ts @@ -51,7 +51,7 @@ describe("resolvers -> Mutation -> updateLanguage", () => { const updateLanguagePayload = await updateLanguageResolver?.( {}, args, - context + context, ); const testUpdateLanguagePayload = await User.findOne({ diff --git a/tests/resolvers/Mutation/updateOrganization.spec.ts b/tests/resolvers/Mutation/updateOrganization.spec.ts index c81b3260ede..dd1e08bcf64 100644 --- a/tests/resolvers/Mutation/updateOrganization.spec.ts +++ b/tests/resolvers/Mutation/updateOrganization.spec.ts @@ -80,7 +80,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(ORGANIZATION_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -110,7 +110,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -124,7 +124,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { $set: { admins: [testUser?._id], }, - } + }, ); await User.updateOne( @@ -135,7 +135,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { $set: { adminFor: [testOrganization?._id], }, - } + }, ); const args: MutationUpdateOrganizationArgs = { @@ -159,7 +159,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { const updateOrganizationPayload = await updateOrganizationResolver?.( {}, args, - context + context, ); const testUpdateOrganizationPayload = await Organization.findOne({ @@ -178,7 +178,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { $set: { admins: [testUser?._id], }, - } + }, ); await User.updateOne( @@ -189,7 +189,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { $set: { adminFor: [testOrganization?._id], }, - } + }, ); const args: MutationUpdateOrganizationArgs = { @@ -205,7 +205,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { }; vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const context = { @@ -215,7 +215,7 @@ describe("resolvers -> Mutation -> updateOrganization", () => { const updateOrganizationPayload = await updateOrganizationResolver?.( {}, args, - context + context, ); const testUpdateOrganizationPayload = await Organization.findOne({ diff --git a/tests/resolvers/Mutation/updatePluginStatus.spec.ts b/tests/resolvers/Mutation/updatePluginStatus.spec.ts index a530a1690cb..de321c2c164 100644 --- a/tests/resolvers/Mutation/updatePluginStatus.spec.ts +++ b/tests/resolvers/Mutation/updatePluginStatus.spec.ts @@ -92,7 +92,7 @@ describe("resolvers -> Mutation -> updatePluginStatus", () => { const updatePluginStatusPayload = await updatePluginStatus?.( {}, args, - context + context, ); const testUpdatePluginStatusPayload = await Plugin.findOne({ @@ -121,7 +121,7 @@ describe("resolvers -> Mutation -> updatePluginStatus", () => { const updatePluginStatusPayload = await updatePluginStatus?.( {}, args, - context + context, ); const testUpdatePluginStatusPayload = await Plugin.findOne({ diff --git a/tests/resolvers/Mutation/updatePost.spec.ts b/tests/resolvers/Mutation/updatePost.spec.ts index 828f1d1ad88..11307fa19a8 100644 --- a/tests/resolvers/Mutation/updatePost.spec.ts +++ b/tests/resolvers/Mutation/updatePost.spec.ts @@ -32,7 +32,7 @@ beforeEach(async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); }); afterEach(async () => { @@ -69,7 +69,7 @@ describe("resolvers -> Mutation -> updatePost", () => { await Post.updateOne( { _id: testPost?._id }, - { $set: { creatorId: Types.ObjectId().toString() } } + { $set: { creatorId: Types.ObjectId().toString() } }, ); await updatePostResolver?.({}, args, context); @@ -147,7 +147,7 @@ describe("resolvers -> Mutation -> updatePost", () => { it(`throws String Length Validation error if title is greater than 256 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationUpdatePostArgs = { @@ -172,14 +172,14 @@ describe("resolvers -> Mutation -> updatePost", () => { await updatePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 256 characters in title`, ); } }); it(`throws String Length Validation error if text is greater than 500 characters`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationUpdatePostArgs = { @@ -203,7 +203,7 @@ describe("resolvers -> Mutation -> updatePost", () => { await updatePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information` + `${LENGTH_VALIDATION_ERROR.MESSAGE} 500 characters in information`, ); } }); @@ -211,7 +211,7 @@ describe("resolvers -> Mutation -> updatePost", () => { it("throws error if title is provided and post is not pinned", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationUpdatePostArgs = { @@ -233,7 +233,7 @@ describe("resolvers -> Mutation -> updatePost", () => { await updatePostResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Post needs to be pinned inorder to add a title` + `Post needs to be pinned inorder to add a title`, ); } }); @@ -241,7 +241,7 @@ describe("resolvers -> Mutation -> updatePost", () => { it(`throws error if title is not provided and post is pinned`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementationOnce( - (message) => message + (message) => message, ); try { const args: MutationUpdatePostArgs = { diff --git a/tests/resolvers/Mutation/updateUserPassword.spec.ts b/tests/resolvers/Mutation/updateUserPassword.spec.ts index 4cf36b17d36..09a1db0ba28 100644 --- a/tests/resolvers/Mutation/updateUserPassword.spec.ts +++ b/tests/resolvers/Mutation/updateUserPassword.spec.ts @@ -84,7 +84,7 @@ describe("resolvers -> Mutation -> updateUserPassword", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -93,7 +93,7 @@ describe("resolvers -> Mutation -> updateUserPassword", () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { @@ -122,7 +122,7 @@ describe("resolvers -> Mutation -> updateUserPassword", () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { @@ -152,7 +152,7 @@ describe("resolvers -> Mutation -> updateUserPassword", () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { @@ -194,7 +194,7 @@ describe("resolvers -> Mutation -> updateUserPassword", () => { const updateUserPasswordPayload = await updateUserPasswordResolver?.( {}, args, - context + context, ); expect(updateUserPasswordPayload).not.toBeNull(); diff --git a/tests/resolvers/Mutation/updateUserProfile.spec.ts b/tests/resolvers/Mutation/updateUserProfile.spec.ts index e9018cd6053..846026af4a3 100644 --- a/tests/resolvers/Mutation/updateUserProfile.spec.ts +++ b/tests/resolvers/Mutation/updateUserProfile.spec.ts @@ -110,7 +110,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -138,7 +138,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -169,7 +169,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(EMAIL_ALREADY_EXISTS_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${EMAIL_ALREADY_EXISTS_ERROR.MESSAGE}` + `Translated ${EMAIL_ALREADY_EXISTS_ERROR.MESSAGE}`, ); } }); @@ -199,7 +199,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(EMAIL_ALREADY_EXISTS_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${EMAIL_ALREADY_EXISTS_ERROR.MESSAGE}` + `Translated ${EMAIL_ALREADY_EXISTS_ERROR.MESSAGE}`, ); } }); @@ -218,7 +218,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); expect(updateUserProfilePayload).toEqual({ @@ -243,7 +243,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); expect(updateUserProfilePayload).toEqual({ @@ -271,7 +271,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); const testUserobj = await User.findById({ _id: testUser.id }); @@ -301,7 +301,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); const testUserobj = await User.findById({ _id: testUser.id }); @@ -333,7 +333,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); expect(updateUserProfilePayload).toEqual({ @@ -358,7 +358,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { }; vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const context = { @@ -369,7 +369,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); expect(updateUserProfilePayload).toEqual({ @@ -389,7 +389,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { }; vi.spyOn(uploadEncodedImage, "uploadEncodedImage").mockImplementation( - async (encodedImageURL: string) => encodedImageURL + async (encodedImageURL: string) => encodedImageURL, ); const context = { @@ -400,7 +400,7 @@ describe("resolvers -> Mutation -> updateUserProfile", () => { const updateUserProfilePayload = await updateUserProfileResolver?.( {}, args, - context + context, ); expect(updateUserProfilePayload).toEqual({ diff --git a/tests/resolvers/Mutation/updateUserRoleInOrganization.spec.ts b/tests/resolvers/Mutation/updateUserRoleInOrganization.spec.ts index deef8e6e908..d285d09c3c5 100644 --- a/tests/resolvers/Mutation/updateUserRoleInOrganization.spec.ts +++ b/tests/resolvers/Mutation/updateUserRoleInOrganization.spec.ts @@ -105,7 +105,7 @@ beforeAll(async () => { adminFor: [testOrganization?._id], joinedOrganizations: [testOrganization?._id], }, - } + }, ); await User.updateOne( { @@ -116,7 +116,7 @@ beforeAll(async () => { adminFor: [testOrganization?._id], joinedOrganizations: [testOrganization?._id], }, - } + }, ); await User.updateOne( { @@ -126,7 +126,7 @@ beforeAll(async () => { $set: { joinedOrganizations: [testOrganization?._id], }, - } + }, ); }); @@ -142,7 +142,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when organization does not exists`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -167,7 +167,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when user whose role to be changed does not exists`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -192,7 +192,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when user whose role to be changed is not a member of the organization`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -217,7 +217,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when logged in user does not exists`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -242,7 +242,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when USER is trying to change role of an admin`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -267,7 +267,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when ADMIN of another org is not allowed to change role`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -292,7 +292,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when logged in ADMIN member user is not allowed to change the user type to SUPERADMIN`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -317,7 +317,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when logged in ADMIN member user is trying to change the role of the itself`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -342,7 +342,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when logged in ADMIN member user is trying to change the role of the org creator`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); try { const args: MutationUpdateUserRoleInOrganizationArgs = { @@ -367,7 +367,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when SUPERUSER is changing the role of a USER member to ADMIN`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const args: MutationUpdateUserRoleInOrganizationArgs = { organizationId: testOrganization?._id, @@ -392,10 +392,10 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { }).lean(); const updatedOrganizationCheck = updatedOrganization?.admins.some( - (member) => member.equals(testMemberUser?._id) + (member) => member.equals(testMemberUser?._id), ); const updatedUserCheck = updatedUser?.adminFor.some((organization) => - organization.equals(testOrganization?._id) + organization.equals(testOrganization?._id), ); expect(updatedOrganizationCheck).toBe(true); expect(updatedUserCheck).toBe(true); @@ -403,7 +403,7 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { it(`Check when SUPERUSER is changing the role of a ADMIN member to USER`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const args: MutationUpdateUserRoleInOrganizationArgs = { organizationId: testOrganization?._id, @@ -428,10 +428,10 @@ describe("resolvers -> Mutation -> updateUserRoleInOrganization", () => { }).lean(); const updatedOrgCheck = updatedOrg?.admins.some((member) => - member.equals(testAdminUser?._id) + member.equals(testAdminUser?._id), ); const updatedUserCheck = updatedUser?.adminFor.some((organization) => - organization.equals(testOrganization?._id) + organization.equals(testOrganization?._id), ); expect(updatedOrgCheck).toBe(false); diff --git a/tests/resolvers/Mutation/updateUserTag.spec.ts b/tests/resolvers/Mutation/updateUserTag.spec.ts index 9b6d946bcf6..a756a330cad 100644 --- a/tests/resolvers/Mutation/updateUserTag.spec.ts +++ b/tests/resolvers/Mutation/updateUserTag.spec.ts @@ -73,7 +73,7 @@ describe("resolvers -> Mutation -> updateUserTag", () => { await updateUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -135,10 +135,10 @@ describe("resolvers -> Mutation -> updateUserTag", () => { await updateUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}` + `${USER_NOT_AUTHORIZED_ERROR.MESSAGE}`, ); } }); @@ -169,7 +169,7 @@ describe("resolvers -> Mutation -> updateUserTag", () => { await updateUserTagResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${NO_CHANGE_IN_TAG_NAME.MESSAGE}` + `Translated ${NO_CHANGE_IN_TAG_NAME.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(`${NO_CHANGE_IN_TAG_NAME.MESSAGE}`); } diff --git a/tests/resolvers/Mutation/updateUserType.spec.ts b/tests/resolvers/Mutation/updateUserType.spec.ts index 9de06f751d7..645ebbc57ad 100644 --- a/tests/resolvers/Mutation/updateUserType.spec.ts +++ b/tests/resolvers/Mutation/updateUserType.spec.ts @@ -67,7 +67,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -97,7 +97,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); } }); @@ -118,7 +118,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { }, { new: true, - } + }, ); const args: MutationUpdateUserTypeArgs = { @@ -139,7 +139,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -168,7 +168,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(SUPERADMIN_CANT_CHANGE_OWN_ROLE.MESSAGE); expect(error.message).toEqual( - `Translated ${SUPERADMIN_CANT_CHANGE_OWN_ROLE.MESSAGE}` + `Translated ${SUPERADMIN_CANT_CHANGE_OWN_ROLE.MESSAGE}`, ); } }); @@ -176,7 +176,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { it(`updates user.userType of user with _id === args.data.id to args.data.userType`, async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => `Translated ${message}` + (message) => `Translated ${message}`, ); await User.updateOne( @@ -188,7 +188,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { }, { new: true, - } + }, ); const args: MutationUpdateUserTypeArgs = { @@ -208,7 +208,7 @@ describe("resolvers -> Mutation -> updateUserType", () => { const updateUserTypePayload = await updateUserTypeResolver?.( {}, args, - context + context, ); expect(updateUserTypePayload).toEqual(true); diff --git a/tests/resolvers/Organization/actionItemCategories.spec.ts b/tests/resolvers/Organization/actionItemCategories.spec.ts index ac51d984f86..051f6ae67c0 100644 --- a/tests/resolvers/Organization/actionItemCategories.spec.ts +++ b/tests/resolvers/Organization/actionItemCategories.spec.ts @@ -26,7 +26,7 @@ describe("resolvers -> Organization -> actionItemCategories", () => { const actionCategoriesPayload = await actionItemCategoriesResolver?.( parent, {}, - {} + {}, ); const categories = await ActionItemCategory.find({ diff --git a/tests/resolvers/Organization/creator.spec.ts b/tests/resolvers/Organization/creator.spec.ts index 7914a805811..e503e73d58a 100644 --- a/tests/resolvers/Organization/creator.spec.ts +++ b/tests/resolvers/Organization/creator.spec.ts @@ -59,7 +59,7 @@ describe("resolvers -> Organization -> creatorId", () => { }, { new: true, - } + }, ); const parent = testOrganization?.toObject(); @@ -73,7 +73,7 @@ describe("resolvers -> Organization -> creatorId", () => { } catch (error: any) { expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); @@ -90,7 +90,7 @@ describe("resolvers -> Organization -> creatorId", () => { }, { new: true, - } + }, ); const parent = testOrganization?.toObject(); diff --git a/tests/resolvers/Organization/image.spec.ts b/tests/resolvers/Organization/image.spec.ts index 145061fdda6..81124c80dc0 100644 --- a/tests/resolvers/Organization/image.spec.ts +++ b/tests/resolvers/Organization/image.spec.ts @@ -50,7 +50,7 @@ describe("resolvers -> Organization -> image", () => { }, { new: true, - } + }, ); const parent = testOrganization?.toObject(); @@ -82,7 +82,7 @@ describe("resolvers -> Organization -> image", () => { }, { new: true, - } + }, ); const parent = testOrganization?.toObject(); diff --git a/tests/resolvers/Organization/membershipRequests.spec.ts b/tests/resolvers/Organization/membershipRequests.spec.ts index cf2a2f912ba..2e79e473a61 100644 --- a/tests/resolvers/Organization/membershipRequests.spec.ts +++ b/tests/resolvers/Organization/membershipRequests.spec.ts @@ -36,7 +36,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); testOrganization = await Organization.findOneAndUpdate( @@ -50,7 +50,7 @@ beforeAll(async () => { }, { new: true, - } + }, ); }); @@ -66,7 +66,7 @@ describe("resolvers -> Organization -> membershipRequests", () => { const membershipRequestsPayload = await membershipRequestsResolver?.( parent, {}, - {} + {}, ); const membershipRequests = await MembershipRequest.find({ diff --git a/tests/resolvers/Organization/pinnedPosts.spec.ts b/tests/resolvers/Organization/pinnedPosts.spec.ts index 77109d2f822..1ffe70a1ccb 100644 --- a/tests/resolvers/Organization/pinnedPosts.spec.ts +++ b/tests/resolvers/Organization/pinnedPosts.spec.ts @@ -27,7 +27,7 @@ beforeAll(async () => { $push: { pinnedPosts: testPost?.id, }, - } + }, ); }); diff --git a/tests/resolvers/Post/comments.spec.ts b/tests/resolvers/Post/comments.spec.ts index 74573a61585..671e9223761 100644 --- a/tests/resolvers/Post/comments.spec.ts +++ b/tests/resolvers/Post/comments.spec.ts @@ -29,7 +29,7 @@ beforeAll(async () => { $inc: { commentCount: 1, }, - } + }, ); }); @@ -44,7 +44,7 @@ describe("resolvers -> Post -> comments", () => { const commentsPayload = await commentsResolver?.( parent!.toObject(), {}, - {} + {}, ); const comments = await Comment.find({ @@ -59,7 +59,7 @@ describe("resolvers -> Post -> comments", () => { const commentsPayload = await commentsResolver?.( parent!.toObject(), {}, - {} + {}, ); const comments = await Comment.find({ diff --git a/tests/resolvers/Query/actionItem.spec.ts b/tests/resolvers/Query/actionItem.spec.ts index 88dbbc4d421..efd65f9b3f9 100644 --- a/tests/resolvers/Query/actionItem.spec.ts +++ b/tests/resolvers/Query/actionItem.spec.ts @@ -45,7 +45,7 @@ describe("resolvers -> Query -> actionItem", () => { expect(actionItemPayload).toEqual( expect.objectContaining({ _id: testActionItem?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Query/actionItemCategoriesByOrganization.spec.ts b/tests/resolvers/Query/actionItemCategoriesByOrganization.spec.ts index 1889c27e85d..c23f6734733 100644 --- a/tests/resolvers/Query/actionItemCategoriesByOrganization.spec.ts +++ b/tests/resolvers/Query/actionItemCategoriesByOrganization.spec.ts @@ -34,7 +34,7 @@ describe("resolvers -> Query -> actionItemCategoriesByOrganization", () => { }).lean(); expect(categoriesByOrganizationPayload).toEqual( - categoriesByOrganizationInfo + categoriesByOrganizationInfo, ); }); }); diff --git a/tests/resolvers/Query/actionItemCategory.spec.ts b/tests/resolvers/Query/actionItemCategory.spec.ts index dbccdfd506c..94a4342e129 100644 --- a/tests/resolvers/Query/actionItemCategory.spec.ts +++ b/tests/resolvers/Query/actionItemCategory.spec.ts @@ -43,13 +43,13 @@ describe("resolvers -> Query -> actionItemCategory", () => { const actionItemCategoryPayload = await actionItemCategoryResolver?.( {}, args, - {} + {}, ); expect(actionItemCategoryPayload).toEqual( expect.objectContaining({ _id: testCategory?._id, - }) + }), ); }); }); diff --git a/tests/resolvers/Query/actionItemsByEvent.spec.ts b/tests/resolvers/Query/actionItemsByEvent.spec.ts index 34f161eee76..022b3688d16 100644 --- a/tests/resolvers/Query/actionItemsByEvent.spec.ts +++ b/tests/resolvers/Query/actionItemsByEvent.spec.ts @@ -29,7 +29,7 @@ describe("resolvers -> Query -> actionItemsByEvent", () => { const actionItemsByEventPayload = await actionItemsByEventsResolver?.( {}, args, - {} + {}, ); const actionItemsByEventInfo = await ActionItem.find({ diff --git a/tests/resolvers/Query/actionItemsByOrganization.spec.ts b/tests/resolvers/Query/actionItemsByOrganization.spec.ts index 3c6c3326dce..260c225d129 100644 --- a/tests/resolvers/Query/actionItemsByOrganization.spec.ts +++ b/tests/resolvers/Query/actionItemsByOrganization.spec.ts @@ -35,7 +35,7 @@ describe("resolvers -> Query -> actionItemsByOrganization", () => { organizationId: args.organizationId, }); const actionItemCategoriesIds = actionItemCategories.map( - (category) => category._id + (category) => category._id, ); const actionItemsByOrganizationInfo = await ActionItem.find({ @@ -43,7 +43,7 @@ describe("resolvers -> Query -> actionItemsByOrganization", () => { }).lean(); expect(actionItemsByOrganizationPayload).toEqual( - actionItemsByOrganizationInfo + actionItemsByOrganizationInfo, ); }); }); diff --git a/tests/resolvers/Query/checkAuth.spec.ts b/tests/resolvers/Query/checkAuth.spec.ts index 1f44d09f283..4fb8562f23e 100644 --- a/tests/resolvers/Query/checkAuth.spec.ts +++ b/tests/resolvers/Query/checkAuth.spec.ts @@ -53,7 +53,7 @@ describe("resolvers -> Query -> checkAuth", () => { }, { image: `path`, - } + }, ); testUser = await User.findOne({ diff --git a/tests/resolvers/Query/customDataByOrganization.spec.ts b/tests/resolvers/Query/customDataByOrganization.spec.ts index c24e76ba2e1..9dac8d8dd4e 100644 --- a/tests/resolvers/Query/customDataByOrganization.spec.ts +++ b/tests/resolvers/Query/customDataByOrganization.spec.ts @@ -33,7 +33,7 @@ describe("resolvers => Query => customDataByOrganization", () => { dataName: "testDataName", dataValue: "testDataValue", }, - { userId: testUser?._id } + { userId: testUser?._id }, ); const args = { diff --git a/tests/resolvers/Query/customFieldsByOrganization.spec.ts b/tests/resolvers/Query/customFieldsByOrganization.spec.ts index 6d017a05ff9..1e068aea700 100644 --- a/tests/resolvers/Query/customFieldsByOrganization.spec.ts +++ b/tests/resolvers/Query/customFieldsByOrganization.spec.ts @@ -35,7 +35,7 @@ describe("resolvers => Query => customFieldsByOrganization", () => { name: "dataName", type: "dataType", }, - { userId: testUser?._id } + { userId: testUser?._id }, ); const args = { @@ -65,7 +65,7 @@ describe("resolvers => Query => customFieldsByOrganization", () => { name: "dataName", type: "dataType", }, - { userId: testUser?._id } + { userId: testUser?._id }, ); const args = { @@ -79,10 +79,10 @@ describe("resolvers => Query => customFieldsByOrganization", () => { await customFieldsByOrganization?.({}, args, context); } catch (error: any) { expect(spy).toHaveBeenLastCalledWith( - ORGANIZATION_NOT_FOUND_ERROR.MESSAGE + ORGANIZATION_NOT_FOUND_ERROR.MESSAGE, ); expect(error.message).toEqual( - `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${ORGANIZATION_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/resolvers/Query/directChatsByUserID.spec.ts b/tests/resolvers/Query/directChatsByUserID.spec.ts index d3e6722cf90..75bce891acf 100644 --- a/tests/resolvers/Query/directChatsByUserID.spec.ts +++ b/tests/resolvers/Query/directChatsByUserID.spec.ts @@ -46,7 +46,7 @@ describe("resolvers -> Query -> directChatsByUserID", () => { const directChatsByUserIdPayload = await directChatsByUserIDResolver?.( {}, args, - {} + {}, ); const directChatsByUserId = await DirectChat.find({ diff --git a/tests/resolvers/Query/directChatsMessagesByChatID.spec.ts b/tests/resolvers/Query/directChatsMessagesByChatID.spec.ts index 96bb19d4ce3..70f952cc63d 100644 --- a/tests/resolvers/Query/directChatsMessagesByChatID.spec.ts +++ b/tests/resolvers/Query/directChatsMessagesByChatID.spec.ts @@ -30,19 +30,19 @@ beforeAll(async () => { const testDirectChat1 = await createTestDirectChatwithUsers( testUser1?._id, testOrganization?._id, - [testUser1?._id, testUser2?._id] + [testUser1?._id, testUser2?._id], ); const testDirectChat2 = await createTestDirectChatwithUsers( testUser2?._id, testOrganization?._id, - [testUser2?._id] + [testUser2?._id], ); testDirectChats = [testDirectChat1, testDirectChat2]; await createDirectChatMessage( testUser1?._id, testUser2?._id, - testDirectChats[0]?._id + testDirectChats[0]?._id, ); }); @@ -90,7 +90,7 @@ describe("resolvers -> Query -> directChatsMessagesByChatID", () => { }).lean(); expect(directChatsMessagesByChatIdPayload).toEqual( - directChatMessagesByChatId + directChatMessagesByChatId, ); }); }); diff --git a/tests/resolvers/Query/eventsByOrganization.spec.ts b/tests/resolvers/Query/eventsByOrganization.spec.ts index cf5032cc5e8..d2cbe870776 100644 --- a/tests/resolvers/Query/eventsByOrganization.spec.ts +++ b/tests/resolvers/Query/eventsByOrganization.spec.ts @@ -22,13 +22,13 @@ beforeAll(async () => { testUser?._id, testOrganization?._id, true, - "ONCE" + "ONCE", ); const testEvent2 = await createEventWithRegistrant( testUser?._id, testOrganization?._id, true, - "ONCE" + "ONCE", ); }); @@ -53,7 +53,7 @@ describe("resolvers -> Query -> eventsByOrganization", () => { const eventsByOrganizationPayload = await eventsByOrganization?.( {}, args, - {} + {}, ); const eventsByOrganizationInfo = await Event.find({ diff --git a/tests/resolvers/Query/eventsByOrganizationConnection.spec.ts b/tests/resolvers/Query/eventsByOrganizationConnection.spec.ts index 5e450709bca..627857b5d51 100644 --- a/tests/resolvers/Query/eventsByOrganizationConnection.spec.ts +++ b/tests/resolvers/Query/eventsByOrganizationConnection.spec.ts @@ -20,19 +20,19 @@ beforeAll(async () => { testUser?._id, testOrganization?._id, true, - "ONCE" + "ONCE", ); const testEvent2 = await createEventWithRegistrant( testUser?._id, testOrganization?._id, false, - "DAILY" + "DAILY", ); const testEvent3 = await createEventWithRegistrant( testUser?._id, testOrganization?._id, false, - "DAILY" + "DAILY", ); testEvents = [testEvent1, testEvent2, testEvent3]; }); diff --git a/tests/resolvers/Query/getDonationById.spec.ts b/tests/resolvers/Query/getDonationById.spec.ts index 137591112db..605894ef28e 100644 --- a/tests/resolvers/Query/getDonationById.spec.ts +++ b/tests/resolvers/Query/getDonationById.spec.ts @@ -29,7 +29,7 @@ describe("resolvers -> Mutation -> getDonationById", () => { const getDonationByIdPayload = await getDonationByIdResolver?.( {}, args, - {} + {}, ); expect(getDonationByIdPayload).toEqual(testDonation?.toObject()); @@ -42,7 +42,7 @@ describe("resolvers -> Mutation -> getDonationById", () => { const getDonationByIdPayload = await getDonationByIdResolver?.( {}, args, - {} + {}, ); expect(getDonationByIdPayload).toEqual({}); diff --git a/tests/resolvers/Query/getDonationByOrgId.spec.ts b/tests/resolvers/Query/getDonationByOrgId.spec.ts index be14a8f939f..9f17ed583ad 100644 --- a/tests/resolvers/Query/getDonationByOrgId.spec.ts +++ b/tests/resolvers/Query/getDonationByOrgId.spec.ts @@ -30,7 +30,7 @@ describe("resolvers -> Mutation -> getDonationByOrgId", () => { const getDonationByOrgIdPayload = await getDonationByOrgIdResolver?.( {}, args, - {} + {}, ); const donationsByOrganization = await Donation.find({ diff --git a/tests/resolvers/Query/getDonationByOrgIdConnection.spec.ts b/tests/resolvers/Query/getDonationByOrgIdConnection.spec.ts index 6052214bbcb..f109b9178fb 100644 --- a/tests/resolvers/Query/getDonationByOrgIdConnection.spec.ts +++ b/tests/resolvers/Query/getDonationByOrgIdConnection.spec.ts @@ -44,7 +44,7 @@ describe("resolvers -> Query -> getDonationByOrgIdConnection", () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -66,7 +66,7 @@ describe("resolvers -> Query -> getDonationByOrgIdConnection", () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -88,7 +88,7 @@ describe("resolvers -> Query -> getDonationByOrgIdConnection", () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -110,7 +110,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -132,7 +132,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -154,7 +154,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -176,7 +176,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -198,7 +198,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -220,7 +220,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -244,7 +244,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); @@ -270,7 +270,7 @@ args.where === { id_not_in: testDonations[2]._id }`, async () => { }).lean(); expect(getDonationByOrgIdConnectionPayload).toEqual( - donationsByOrganization + donationsByOrganization, ); }); }); diff --git a/tests/resolvers/Query/getlanguage.spec.ts b/tests/resolvers/Query/getlanguage.spec.ts index 1c207c5f910..c0430e0a734 100644 --- a/tests/resolvers/Query/getlanguage.spec.ts +++ b/tests/resolvers/Query/getlanguage.spec.ts @@ -81,7 +81,7 @@ describe("resolvers -> Query -> getLanguage", () => { translation: "value2", verified: false, }), - ]) + ]), ); }); }); diff --git a/tests/resolvers/Query/hasSubmittedFeedback.spec.ts b/tests/resolvers/Query/hasSubmittedFeedback.spec.ts index 10e903074e0..d20134c556f 100644 --- a/tests/resolvers/Query/hasSubmittedFeedback.spec.ts +++ b/tests/resolvers/Query/hasSubmittedFeedback.spec.ts @@ -52,7 +52,7 @@ describe("resolvers -> Query -> hasSubmittedFeedback", () => { await hasSubmittedFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); } @@ -79,7 +79,7 @@ describe("resolvers -> Query -> hasSubmittedFeedback", () => { await hasSubmittedFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${EVENT_NOT_FOUND_ERROR.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(EVENT_NOT_FOUND_ERROR.MESSAGE); } @@ -106,10 +106,10 @@ describe("resolvers -> Query -> hasSubmittedFeedback", () => { await hasSubmittedFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}` + `Translated ${USER_NOT_REGISTERED_FOR_EVENT.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith( - USER_NOT_REGISTERED_FOR_EVENT.MESSAGE + USER_NOT_REGISTERED_FOR_EVENT.MESSAGE, ); } }); @@ -141,7 +141,7 @@ describe("resolvers -> Query -> hasSubmittedFeedback", () => { await hasSubmittedFeedbackResolver?.({}, args, context); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_CHECKED_IN.MESSAGE}` + `Translated ${USER_NOT_CHECKED_IN.MESSAGE}`, ); expect(spy).toHaveBeenLastCalledWith(USER_NOT_CHECKED_IN.MESSAGE); } diff --git a/tests/resolvers/Query/organizationIsSample.spec.ts b/tests/resolvers/Query/organizationIsSample.spec.ts index e831ca00045..4ea802caa4b 100644 --- a/tests/resolvers/Query/organizationIsSample.spec.ts +++ b/tests/resolvers/Query/organizationIsSample.spec.ts @@ -20,7 +20,7 @@ describe("determine whether organization is a sample or not", async () => { it("isSampleOrganization should return true if organizationId exists in SampleData collection", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const _id = faker.database.mongodbObjectId(); @@ -68,7 +68,7 @@ describe("determine whether organization is a sample or not", async () => { it("isSampleOrganization should return false if organizationId does not exist in SampleData collection", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const _id = faker.database.mongodbObjectId(); @@ -108,7 +108,7 @@ describe("ensure organization exists in organization collection", async () => { it("should throw error when organization doesn't exist in the 'Organization' collection", async () => { const { requestContext } = await import("../../../src/libraries"); vi.spyOn(requestContext, "translate").mockImplementation( - (message) => message + (message) => message, ); const randomId = faker.database.mongodbObjectId(); diff --git a/tests/resolvers/Query/organizationsConnection.spec.ts b/tests/resolvers/Query/organizationsConnection.spec.ts index a849779b05f..fd82e219d1b 100644 --- a/tests/resolvers/Query/organizationsConnection.spec.ts +++ b/tests/resolvers/Query/organizationsConnection.spec.ts @@ -74,7 +74,7 @@ beforeAll(async () => { testOrganizations[2]._id, ], }, - } + }, ); }); diff --git a/tests/resolvers/Query/organizationsMemberConnection.spec.ts b/tests/resolvers/Query/organizationsMemberConnection.spec.ts index 75aed8a2759..e74d3536d89 100644 --- a/tests/resolvers/Query/organizationsMemberConnection.spec.ts +++ b/tests/resolvers/Query/organizationsMemberConnection.spec.ts @@ -65,7 +65,7 @@ beforeAll(async () => { adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); await User.updateOne( @@ -77,7 +77,7 @@ beforeAll(async () => { adminFor: testOrganization._id, joinedOrganizations: testOrganization._id, }, - } + }, ); await User.updateOne( @@ -89,7 +89,7 @@ beforeAll(async () => { adminFor: [testOrganization._id], joinedOrganizations: [testOrganization._id], }, - } + }, ); }); @@ -797,7 +797,7 @@ describe("resolvers -> Query -> organizationsMemberConnection", () => { await organizationsMemberConnectionResolver?.({}, args, {}); } catch (error: any) { expect(error).toEqual( - "Missing Skip parameter. Set it to either 0 or some other value" + "Missing Skip parameter. Set it to either 0 or some other value", ); } }); @@ -873,7 +873,7 @@ describe("resolvers -> Query -> organizationsMemberConnection", () => { $set: { image: `image/image.png`, }, - } + }, ); const where = { joinedOrganizations: { @@ -937,7 +937,7 @@ describe("resolvers -> Query -> organizationsMemberConnection", () => { $set: { image: `image/image.png`, }, - } + }, ); const where = { joinedOrganizations: { diff --git a/tests/resolvers/Query/postsByOrganization.spec.ts b/tests/resolvers/Query/postsByOrganization.spec.ts index 9e01cf9f786..a0cac7c2a92 100644 --- a/tests/resolvers/Query/postsByOrganization.spec.ts +++ b/tests/resolvers/Query/postsByOrganization.spec.ts @@ -45,7 +45,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -82,7 +82,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -118,7 +118,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -154,7 +154,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -190,7 +190,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ organization: testOrganization?._id, @@ -226,7 +226,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ organization: testOrganization?._id, @@ -261,7 +261,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -297,7 +297,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -333,7 +333,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -369,7 +369,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -406,7 +406,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -442,7 +442,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -479,7 +479,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -515,7 +515,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -551,7 +551,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -587,7 +587,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ organization: testOrganization?._id, @@ -622,7 +622,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ @@ -650,7 +650,7 @@ describe("resolvers -> Query -> posts", () => { $set: { imageUrl: undefined, }, - } + }, ); const sort = { @@ -669,7 +669,7 @@ describe("resolvers -> Query -> posts", () => { const postsByOrganizationPayload = await postsByOrganizationResolver?.( {}, args, - context + context, ); const postsByOrganization = await Post.find({ diff --git a/tests/resolvers/Query/postsByOrganizationConnection.spec.ts b/tests/resolvers/Query/postsByOrganizationConnection.spec.ts index 30bf0ff05e1..90f6f563fd7 100644 --- a/tests/resolvers/Query/postsByOrganizationConnection.spec.ts +++ b/tests/resolvers/Query/postsByOrganizationConnection.spec.ts @@ -251,7 +251,7 @@ describe("resolvers -> Query -> postsByOrganizationConnection", () => { $set: { imageUrl: undefined, }, - } + }, ); const where = { diff --git a/tests/resolvers/Query/user.spec.ts b/tests/resolvers/Query/user.spec.ts index bade5dfd91b..b3e3baefe04 100644 --- a/tests/resolvers/Query/user.spec.ts +++ b/tests/resolvers/Query/user.spec.ts @@ -68,7 +68,7 @@ describe("resolvers -> Query -> user", () => { $set: { image: `images/newImage.png`, }, - } + }, ); const args: QueryUserArgs = { diff --git a/tests/resolvers/Query/users.spec.ts b/tests/resolvers/Query/users.spec.ts index 9cc103f1ca4..3e92f52f52c 100644 --- a/tests/resolvers/Query/users.spec.ts +++ b/tests/resolvers/Query/users.spec.ts @@ -48,7 +48,7 @@ describe("resolvers -> Query -> users", () => { } catch (error: any) { expect(spy).toBeCalledWith(UNAUTHENTICATED_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${UNAUTHENTICATED_ERROR.MESSAGE}` + `Translated ${UNAUTHENTICATED_ERROR.MESSAGE}`, ); } @@ -165,7 +165,7 @@ describe("resolvers -> Query -> users", () => { registeredEvents: testEvent._id, eventAdmin: testEvent._id, }, - } + }, ); await User.updateOne( @@ -177,7 +177,7 @@ describe("resolvers -> Query -> users", () => { joinedOrganizations: testOrganization._id, organizationsBlockedBy: testOrganization._id, }, - } + }, ); await Organization.updateOne( @@ -188,7 +188,7 @@ describe("resolvers -> Query -> users", () => { $push: { blockedUsers: testUsers[1]._id, }, - } + }, ); }); @@ -960,7 +960,7 @@ describe("resolvers -> Query -> users", () => { $set: { image: "images/image.png", }, - } + }, ); const args: QueryUsersArgs = { diff --git a/tests/resolvers/Query/usersConnection.spec.ts b/tests/resolvers/Query/usersConnection.spec.ts index 240c4e3c9af..f0035990785 100644 --- a/tests/resolvers/Query/usersConnection.spec.ts +++ b/tests/resolvers/Query/usersConnection.spec.ts @@ -23,7 +23,7 @@ beforeAll(async () => { testUsers[0]?._id, testOrganization?._id, true, - "ONCE" + "ONCE", ); }); @@ -41,7 +41,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find() .limit(0) @@ -91,7 +91,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -153,7 +153,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -215,7 +215,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -277,7 +277,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -339,7 +339,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -389,7 +389,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -426,7 +426,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -463,7 +463,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -500,7 +500,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -537,7 +537,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) @@ -571,7 +571,7 @@ describe("resolvers -> Query -> usersConnection", () => { const usersConnectionPayload = await usersConnectionResolver?.( {}, args, - {} + {}, ); const users = await User.find(where) diff --git a/tests/resolvers/Subscription/messageSentToDirectChat.spec.ts b/tests/resolvers/Subscription/messageSentToDirectChat.spec.ts index 9c7c037ec2b..1c9999cf78e 100644 --- a/tests/resolvers/Subscription/messageSentToDirectChat.spec.ts +++ b/tests/resolvers/Subscription/messageSentToDirectChat.spec.ts @@ -50,7 +50,7 @@ describe("src -> resolvers -> Subscription -> messageSentToDirectChat", () => { const x = messageSentToDirectChatPayload?.subscribe( _parent, _args, - context + context, ); expect(x).not.toBe(null); expect(await filterFunction(payload, context)).toBe(true); @@ -89,7 +89,7 @@ describe("src -> resolvers -> Subscription -> messageSentToDirectChat", () => { const x = messageSentToDirectChatPayload?.subscribe( _parent, _args, - context + context, ); expect(x).not.toBe(null); expect(await filterFunction(payload, context)).toBe(false); diff --git a/tests/resolvers/UserTag/childTags.spec.ts b/tests/resolvers/UserTag/childTags.spec.ts index 1525fdf211f..40111007386 100644 --- a/tests/resolvers/UserTag/childTags.spec.ts +++ b/tests/resolvers/UserTag/childTags.spec.ts @@ -80,16 +80,16 @@ describe("resolvers -> Tag -> childTags", () => { const payload = (await childTagsResolver?.( parent, args, - {} + {}, )) as UserTagsConnectionResult; expect(payload.errors.length).toEqual(0); expect(payload.data).not.toBeNull(); expect(payload.data!.pageInfo.startCursor).toEqual( - testChildTag1!._id.toString() + testChildTag1!._id.toString(), ); expect(payload.data!.pageInfo.endCursor).toEqual( - testChildTag2!._id.toString() + testChildTag2!._id.toString(), ); expect(payload.data!.edges[0].node).toEqual(testChildTag1); }); diff --git a/tests/resolvers/UserTag/usersAssignedTo.spec.ts b/tests/resolvers/UserTag/usersAssignedTo.spec.ts index 3b67a8d72ae..1403b0c753b 100644 --- a/tests/resolvers/UserTag/usersAssignedTo.spec.ts +++ b/tests/resolvers/UserTag/usersAssignedTo.spec.ts @@ -79,7 +79,7 @@ describe("resolvers -> Tag -> usersAssignedTo", () => { const payload = (await usersAssignedToResolver?.( parent, args, - {} + {}, )) as UsersConnectionResult; expect(payload.errors.length).toEqual(0); @@ -90,10 +90,10 @@ describe("resolvers -> Tag -> usersAssignedTo", () => { }); expect(payload.data!.pageInfo.startCursor).toEqual( - userTagObject!._id.toString() + userTagObject!._id.toString(), ); expect(payload.data!.pageInfo.endCursor).toEqual( - userTagObject!._id.toString() + userTagObject!._id.toString(), ); expect(payload.data!.edges[0].node._id).toEqual(testUser && testUser._id); }); diff --git a/tests/resolvers/middleware/currentUserExists.spec.ts b/tests/resolvers/middleware/currentUserExists.spec.ts index dd178664bf2..c20465ec00d 100644 --- a/tests/resolvers/middleware/currentUserExists.spec.ts +++ b/tests/resolvers/middleware/currentUserExists.spec.ts @@ -53,7 +53,7 @@ describe("resolvers -> Middleware -> currentUserExists", () => { } catch (error: any) { expect(spy).toHaveBeenLastCalledWith(USER_NOT_FOUND_ERROR.MESSAGE); expect(error.message).toEqual( - `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}` + `Translated ${USER_NOT_FOUND_ERROR.MESSAGE}`, ); } }); diff --git a/tests/utilities/adminCheck.spec.ts b/tests/utilities/adminCheck.spec.ts index 674d72042da..f5e80308447 100644 --- a/tests/utilities/adminCheck.spec.ts +++ b/tests/utilities/adminCheck.spec.ts @@ -48,11 +48,11 @@ describe("utilities -> adminCheck", () => { const { adminCheck } = await import("../../src/utilities"); await adminCheck( testUser?._id, - testOrganization ?? ({} as InterfaceOrganization) + testOrganization ?? ({} as InterfaceOrganization), ); } catch (error: any) { expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); @@ -69,7 +69,7 @@ describe("utilities -> adminCheck", () => { { new: true, upsert: true, - } + }, ); const { adminCheck } = await import("../../src/utilities"); @@ -77,8 +77,8 @@ describe("utilities -> adminCheck", () => { await expect( adminCheck( updatedUser?._id, - testOrganization ?? ({} as InterfaceOrganization) - ) + testOrganization ?? ({} as InterfaceOrganization), + ), ).resolves.not.toThrowError(); }); @@ -93,7 +93,7 @@ describe("utilities -> adminCheck", () => { { new: true, upsert: true, - } + }, ); const updatedOrganization = await Organization.findOneAndUpdate( @@ -108,7 +108,7 @@ describe("utilities -> adminCheck", () => { { new: true, upsert: true, - } + }, ); const { adminCheck } = await import("../../src/utilities"); @@ -116,8 +116,8 @@ describe("utilities -> adminCheck", () => { await expect( adminCheck( updatedUser?._id, - updatedOrganization ?? ({} as InterfaceOrganization) - ) + updatedOrganization ?? ({} as InterfaceOrganization), + ), ).resolves.not.toThrowError(); }); it("throws error if user is not found with the specific Id", async () => { @@ -131,12 +131,12 @@ describe("utilities -> adminCheck", () => { const { adminCheck } = await import("../../src/utilities"); await adminCheck( new mongoose.Types.ObjectId(), - testOrganization ?? ({} as InterfaceOrganization) + testOrganization ?? ({} as InterfaceOrganization), ); } catch (error: unknown) { if (!(error instanceof ApplicationError)) return; expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_ADMIN.MESSAGE}`, ); } expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_ADMIN.MESSAGE); diff --git a/tests/utilities/auth.spec.ts b/tests/utilities/auth.spec.ts index 8c6484844b4..4d5512c927f 100644 --- a/tests/utilities/auth.spec.ts +++ b/tests/utilities/auth.spec.ts @@ -34,7 +34,7 @@ afterAll(async () => { describe("createAccessToken", () => { it("should create a JWT token with the correct payload", async () => { const token = createAccessToken( - user ? user.toObject() : ({} as InterfaceUser) + user ? user.toObject() : ({} as InterfaceUser), ); expect(token).toBeDefined(); @@ -43,16 +43,16 @@ describe("createAccessToken", () => { expect(decodedToken).not.toBeNull(); expect((decodedToken as InterfaceJwtTokenPayload).tokenVersion).toBe( - user?.tokenVersion + user?.tokenVersion, ); expect((decodedToken as InterfaceJwtTokenPayload).userId).toBe( - user && user._id ? user._id.toString() : undefined + user && user._id ? user._id.toString() : undefined, ); expect((decodedToken as InterfaceJwtTokenPayload).firstName).toBe( - user?.firstName + user?.firstName, ); expect((decodedToken as InterfaceJwtTokenPayload).lastName).toBe( - user?.lastName + user?.lastName, ); expect((decodedToken as InterfaceJwtTokenPayload).email).toBe(user?.email); }); @@ -61,7 +61,7 @@ describe("createAccessToken", () => { describe("createRefreshToken", () => { it("should create a JWT token with the correct payload", () => { const token = createRefreshToken( - user ? user.toObject() : ({} as InterfaceUser) + user ? user.toObject() : ({} as InterfaceUser), ); expect(token).toBeDefined(); @@ -69,16 +69,16 @@ describe("createRefreshToken", () => { const decodedToken = jwt.decode(token); expect((decodedToken as InterfaceJwtTokenPayload).tokenVersion).toBe( - user?.tokenVersion + user?.tokenVersion, ); expect((decodedToken as InterfaceJwtTokenPayload).userId).toBe( - user && user._id ? user._id.toString() : undefined + user && user._id ? user._id.toString() : undefined, ); expect((decodedToken as InterfaceJwtTokenPayload).firstName).toBe( - user?.firstName + user?.firstName, ); expect((decodedToken as InterfaceJwtTokenPayload).lastName).toBe( - user?.lastName + user?.lastName, ); expect((decodedToken as InterfaceJwtTokenPayload).email).toBe(user?.email); }); diff --git a/tests/utilities/createSampleOrganizationUtil.spec.ts b/tests/utilities/createSampleOrganizationUtil.spec.ts index 54d614e23ec..eed8450e050 100644 --- a/tests/utilities/createSampleOrganizationUtil.spec.ts +++ b/tests/utilities/createSampleOrganizationUtil.spec.ts @@ -87,7 +87,7 @@ describe("generateUserData function", () => { expect(event.startTime).toEqual(expect.any(Date)); expect(event.endTime).toEqual(expect.any(Date)); expect(event.recurrance).toEqual( - expect.stringMatching(/^(ONCE|DAILY|WEEKLY|MONTHLY|YEARLY)$/) + expect.stringMatching(/^(ONCE|DAILY|WEEKLY|MONTHLY|YEARLY)$/), ); expect(event.isPublic).toEqual(expect.any(Boolean)); expect(event.isRegisterable).toEqual(expect.any(Boolean)); @@ -130,7 +130,7 @@ describe("generatePostData function", () => { const pluginPromises = await generateRandomPlugins( numberOfPlugins, - users.map((user) => user._id.toString()) + users.map((user) => user._id.toString()), ); expect(Array.isArray(pluginPromises)).toBe(true); diff --git a/tests/utilities/deleteDuplicatedImage.spec.ts b/tests/utilities/deleteDuplicatedImage.spec.ts index 5afd061440e..ed54af76699 100644 --- a/tests/utilities/deleteDuplicatedImage.spec.ts +++ b/tests/utilities/deleteDuplicatedImage.spec.ts @@ -19,20 +19,20 @@ describe("utilities -> deleteDuplicatedImage", () => { it("should delete duplicated image", () => { vi.spyOn(fs, "unlink").mockImplementationOnce( - (_imagePath: any, callback: any) => callback(null) + (_imagePath: any, callback: any) => callback(null), ); const logSpy = vi.spyOn(logger, "info"); deleteDuplicatedImage(testImagePath); expect(fs.unlink).toBeCalledWith(testImagePath, expect.any(Function)); expect(logSpy).toBeCalledWith( - "File was deleted as it already exists in the db!" + "File was deleted as it already exists in the db!", ); }); it("should throw error", () => { const error = new Error("There was an error deleting the file."); vi.spyOn(fs, "unlink").mockImplementationOnce( - (_imagePath: any, callback: any) => callback(error) + (_imagePath: any, callback: any) => callback(error), ); const logSpy = vi.spyOn(logger, "info"); expect(() => deleteDuplicatedImage(testImagePath)).toThrowError(error); diff --git a/tests/utilities/deleteImage.spec.ts b/tests/utilities/deleteImage.spec.ts index 196b44dc38d..7bc62946c4e 100644 --- a/tests/utilities/deleteImage.spec.ts +++ b/tests/utilities/deleteImage.spec.ts @@ -51,7 +51,7 @@ describe("utilities -> deleteImage.ts", () => { it("should delete Image when numberOfUser <=1", async () => { vi.spyOn(fs, "unlink").mockImplementationOnce( - (_imagePath: any, callback: any) => callback(null) + (_imagePath: any, callback: any) => callback(null), ); const reuploadUtilities = await import( "../../src/utilities/reuploadDuplicateCheck" @@ -60,7 +60,7 @@ describe("utilities -> deleteImage.ts", () => { vi.spyOn(reuploadUtilities, "reuploadDuplicateCheck").mockImplementation( async () => { return false; - } + }, ); const { logger } = await import("../../src/libraries"); @@ -74,10 +74,10 @@ describe("utilities -> deleteImage.ts", () => { expect(fs.unlink).toBeCalledWith( testImageToBeDeleted, - expect.any(Function) + expect.any(Function), ); expect(logSpy).toBeCalledWith( - "Image is only used once and therefore can be deleted" + "Image is only used once and therefore can be deleted", ); expect(logSpy).toBeCalledWith("File deleted!"); expect(testHashObj?.toObject()).toEqual({ @@ -98,7 +98,7 @@ describe("utilities -> deleteImage.ts", () => { }, { new: true, - } + }, ); const reuploadUtilities = await import( @@ -108,7 +108,7 @@ describe("utilities -> deleteImage.ts", () => { vi.spyOn(reuploadUtilities, "reuploadDuplicateCheck").mockImplementation( async () => { return false; - } + }, ); const { logger } = await import("../../src/libraries"); @@ -141,12 +141,12 @@ describe("utilities -> deleteImage.ts", () => { }, { new: true, - } + }, ); const error = new Error("There was an error deleting the file."); vi.spyOn(fs, "unlink").mockImplementationOnce( - (_imagePath: any, callback: any) => callback(error) + (_imagePath: any, callback: any) => callback(error), ); const reuploadUtilities = await import( @@ -156,7 +156,7 @@ describe("utilities -> deleteImage.ts", () => { vi.spyOn(reuploadUtilities, "reuploadDuplicateCheck").mockImplementation( async () => { return false; - } + }, ); const { logger } = await import("../../src/libraries"); @@ -169,7 +169,7 @@ describe("utilities -> deleteImage.ts", () => { expect(fs.unlink).toBeCalledWith( testImageToBeDeleted, - expect.any(Function) + expect.any(Function), ); expect(logSpy).not.toBeCalled(); } catch (error: unknown) { diff --git a/tests/utilities/graphqlConnectionFactory.spec.ts b/tests/utilities/graphqlConnectionFactory.spec.ts index ae220e91f3f..53572c6b627 100644 --- a/tests/utilities/graphqlConnectionFactory.spec.ts +++ b/tests/utilities/graphqlConnectionFactory.spec.ts @@ -168,7 +168,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> F fetchedObjects.slice(0, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -196,7 +196,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> F fetchedObjects.slice(0, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -225,7 +225,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> F fetchedObjects.slice(1, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -254,7 +254,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> F fetchedObjects.slice(1, 1 + getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -309,7 +309,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> B reversedFetchedObjects.slice(0, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -337,7 +337,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> B reversedFetchedObjects.slice(0, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -366,7 +366,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> B reversedFetchedObjects.slice(1, getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ @@ -395,7 +395,7 @@ describe("utilities -> graphqlConnectionFactory -> generateConnectionObject -> B reversedFetchedObjects.slice(1, 1 + getLimit(args.limit)), (x) => ({ _id: x._id, - }) + }), ); expect(payload).toMatchObject({ diff --git a/tests/utilities/imageAlreadyInDbCheck.spec.ts b/tests/utilities/imageAlreadyInDbCheck.spec.ts index 440b8076b25..7effc340a7a 100644 --- a/tests/utilities/imageAlreadyInDbCheck.spec.ts +++ b/tests/utilities/imageAlreadyInDbCheck.spec.ts @@ -106,7 +106,7 @@ describe("utilities -> imageAlreadyInDbCheck", () => { const fileName = await imageAlreadyInDbCheck( testOldImagePath, - testNewImagePath + testNewImagePath, ); expect(fileName).toEqual(testOldImagePath); @@ -153,7 +153,7 @@ describe("utilities -> imageAlreadyInDbCheck", () => { const fileName = await imageAlreadyInDbCheck( testOldImagePath, - testNewImagePath + testNewImagePath, ); const existingImageHash = await ImageHash.findOne({ diff --git a/tests/utilities/mailer.spec.ts b/tests/utilities/mailer.spec.ts index 29c200b1630..9eb0372236f 100644 --- a/tests/utilities/mailer.spec.ts +++ b/tests/utilities/mailer.spec.ts @@ -44,7 +44,7 @@ describe("utilities -> mailer", () => { .mockImplementationOnce(() => { const mockSendMail = ( _mailOptions: Mail.Options, - callBackFn: (_err: Error | null, _info: object) => void + callBackFn: (_err: Error | null, _info: object) => void, ): any => { return callBackFn(null, mockInfo); }; @@ -64,7 +64,7 @@ describe("utilities -> mailer", () => { .mockImplementationOnce(() => { const mockSendMail = ( _mailOptions: Mail.Options, - callBackFn: (_err: Error | null, _info: object | null) => void + callBackFn: (_err: Error | null, _info: object | null) => void, ): any => { return callBackFn(new Error("rejects Promise"), null); }; diff --git a/tests/utilities/reuploadDuplicateCheck.spec.ts b/tests/utilities/reuploadDuplicateCheck.spec.ts index 52cdd374704..4330de27ddf 100644 --- a/tests/utilities/reuploadDuplicateCheck.spec.ts +++ b/tests/utilities/reuploadDuplicateCheck.spec.ts @@ -69,7 +69,7 @@ describe("utilities -> reuploadDuplicateCheck", () => { const reuploadDuplicateCheckPayload = await reuploadDuplicateCheck( testNewImagePathCopy, - testNewImagePath + testNewImagePath, ); expect(reuploadDuplicateCheckPayload).toBe(true); @@ -82,7 +82,7 @@ describe("utilities -> reuploadDuplicateCheck", () => { const reuploadDuplicateCheckPayload = await reuploadDuplicateCheck( null, - testNewImagePath + testNewImagePath, ); expect(reuploadDuplicateCheckPayload).toBe(false); diff --git a/tests/utilities/superAdminCheck.spec.ts b/tests/utilities/superAdminCheck.spec.ts index 780237efbdb..acca9a028ed 100644 --- a/tests/utilities/superAdminCheck.spec.ts +++ b/tests/utilities/superAdminCheck.spec.ts @@ -45,7 +45,7 @@ describe("utilities -> superAdminCheck", () => { } catch (error: unknown) { if (!(error instanceof Error)) return; expect(error.message).toEqual( - `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}` + `Translated ${USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE}`, ); expect(spy).toBeCalledWith(USER_NOT_AUTHORIZED_SUPERADMIN.MESSAGE); } diff --git a/tests/utilities/uploadImage.spec.ts b/tests/utilities/uploadImage.spec.ts index 7562ba64644..21c1a67838c 100644 --- a/tests/utilities/uploadImage.spec.ts +++ b/tests/utilities/uploadImage.spec.ts @@ -62,8 +62,8 @@ try { .createReadStream( path.join( __dirname, - "../../public/markdown/images/talawa-logo-lite-200x200.png" - ) + "../../public/markdown/images/talawa-logo-lite-200x200.png", + ), ) .on("error", (error) => { console.log(error); @@ -79,7 +79,7 @@ try { async (oldImagePath: string | null, newImagePath: string) => { console.log(oldImagePath, newImagePath); return ""; - } + }, ); const { uploadImage } = await import("../../src/utilities/uploadImage"); const uploadImagePayload = await uploadImage(pngImage, null); @@ -94,21 +94,21 @@ try { }, { new: true, - } + }, ).lean(); expect(mockedImageAlreadyInDb).toHaveBeenCalledWith( null, - testUserObj?.image + testUserObj?.image, ); expect(uploadImagePayload?.newImagePath).toEqual(testUserObj?.image); fs.unlink( path.join( __dirname, - "../../".concat(uploadImagePayload.newImagePath) + "../../".concat(uploadImagePayload.newImagePath), ), (err) => { if (err) throw err; - } + }, ); } catch (error) { console.log(error); @@ -123,8 +123,8 @@ try { .createReadStream( path.join( __dirname, - "../../public/markdown/images/talawa-logo-lite-200x200.png" - ) + "../../public/markdown/images/talawa-logo-lite-200x200.png", + ), ) .on("error", (err) => { console.log(err); @@ -140,7 +140,7 @@ try { async (oldImagePath: string | null, newImagePath: string) => { console.log(oldImagePath, newImagePath); return newImagePath; - } + }, ); const { uploadImage } = await import("../../src/utilities/uploadImage"); const testUserBeforeObj = await User.findById({ @@ -167,25 +167,25 @@ try { }, { new: true, - } + }, ).lean(); expect(mockedDeleteImage).toBeCalledWith( oldImagePath, - testUserObj?.image + testUserObj?.image, ); expect(mockedImageAlreadyInDb).toHaveBeenCalledWith( oldImagePath, - testUserObj?.image + testUserObj?.image, ); expect(uploadImagePayload?.newImagePath).toEqual(testUserObj?.image); fs.unlink( path.join( __dirname, - "../../".concat(uploadImagePayload.newImagePath) + "../../".concat(uploadImagePayload.newImagePath), ), (err) => { if (err) throw err; - } + }, ); } catch (error) { console.log(error);