diff --git a/src/gateway/eventHandler.js b/src/gateway/eventHandler.js index 5469e67d..d8498856 100644 --- a/src/gateway/eventHandler.js +++ b/src/gateway/eventHandler.js @@ -145,7 +145,7 @@ class EventHandler { ); const role = new Role(this.#_client, data.role, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.GUILD_ROLE_CREATE, role); @@ -161,7 +161,7 @@ class EventHandler { .get(data.guild_id) ?.roles.get(data.role.id); const newRole = new Role(this.#_client, data.role, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.GUILD_ROLE_UPDATE, oldRole, newRole); @@ -235,7 +235,7 @@ class EventHandler { `THREAD_CREATE ${data.guild_id}`, ); - const thread = new Thread(this.#_client, data, { guild_id: data.guild_id }); + const thread = new Thread(this.#_client, data, { guildId: data.guild_id }); this.#_client.emit(EVENTS.THREAD_CREATE, thread); } @@ -250,7 +250,7 @@ class EventHandler { .get(data.guild_id) ?.channels.get(data.id); const newThread = new Thread(this.#_client, data, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.THREAD_UPDATE, oldThread, newThread); @@ -279,7 +279,7 @@ class EventHandler { const threads = []; for (let i = 0; i < data.threads.length; i++) threads.push( - new Thread(this.#_client, data.threads[i], { guild_id: data.guild_id }), + new Thread(this.#_client, data.threads[i], { guildId: data.guild_id }), ); this.#_client.emit(EVENTS.THREAD_LIST_SYNC, threads); @@ -292,8 +292,8 @@ class EventHandler { ); const member = new Member(this.#_client, data, { - user_id: data.user.id, - guild_id: data.guild_id, + userId: data.user.id, + guildId: data.guild_id, user: data.user, }); @@ -338,8 +338,8 @@ class EventHandler { .get(data.user.id, { useRules: true }) .then((oldMember) => { const newMember = new Member(this.#_client, data, { - user_id: data.user.id, - guild_id: data.guild_id, + userId: data.user.id, + guildId: data.guild_id, user: data.user, }); @@ -355,8 +355,8 @@ class EventHandler { for (let i = 0; i < data.members.length; i++) new Member(this.#_client, data.members[i], { - user_id: data.members[i].user.id, - guild_id: data.guild_id, + userId: data.members[i].user.id, + guildId: data.guild_id, user: data.members[i].user, }); } @@ -393,7 +393,7 @@ class EventHandler { `INVITE_CREATE ${data.guild_id}`, ); - const invite = new Invite(this.#_client, data, { guild_id: data.guild_id }); + const invite = new Invite(this.#_client, data, { guildId: data.guild_id }); this.#_client.emit(EVENTS.INVITE_CREATE, invite); } @@ -425,7 +425,7 @@ class EventHandler { let newVoiceState; if (data.channel_id) newVoiceState = new VoiceState(this.#_client, data, { - guild_id: data.guild_id, + guildId: data.guild_id, }); else { newVoiceState = null; @@ -453,8 +453,8 @@ class EventHandler { ); const message = new Message(this.#_client, data, { - channel_id: data.channel_id, - guild_id: data.guild_id, + channelId: data.channel_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.MESSAGE_CREATE, message); @@ -474,8 +474,8 @@ class EventHandler { .get(data.id, { useRules: true }) .then((oldMessage) => { const newMessage = new Message(this.#_client, data, { - channel_id: data.channel_id, - guild_id: data.guild_id, + channelId: data.channel_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.MESSAGE_UPDATE, oldMessage, newMessage); @@ -536,8 +536,8 @@ class EventHandler { switch (data.data.component_type) { case COMPONENT_TYPES.BUTTON: { const componentInteraction = new ButtonClick(this.#_client, data, { - guild_id: data.guild_id, - channel_id: data.channel_id, + guildId: data.guild_id, + channelId: data.channel_id, }); this.#_client.emit(EVENTS.BUTTON_CLICK, componentInteraction); @@ -551,8 +551,8 @@ class EventHandler { case COMPONENT_TYPES.MENTIONABLE_SELECT_MENU: case COMPONENT_TYPES.CHANNEL_SELECT_MENU: { const componentInteraction = new OptionSelect(this.#_client, data, { - guild_id: data.guild_id, - channel_id: data.channel_id, + guildId: data.guild_id, + channelId: data.channel_id, }); this.#_client.emit(EVENTS.MENU_SELECT, componentInteraction); @@ -606,7 +606,7 @@ class EventHandler { ); const auditLogEntry = new AuditLog(this.#_client, data, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.GUILD_AUDIT_LOG_ENTRY_CREATE, auditLogEntry); @@ -646,7 +646,7 @@ class EventHandler { ); const scheduledEvent = new ScheduledEvent(this.#_client, data, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.GUILD_SCHEDULED_EVENT_CREATE, scheduledEvent); @@ -662,7 +662,7 @@ class EventHandler { this.#_client.guilds.get(data.guild_id)?.scheduled_events.get(data.id) || null; const newScheduledEvent = new ScheduledEvent(this.#_client, data, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit( @@ -799,7 +799,7 @@ class EventHandler { } const addedEmoji = new Emoji(this.#_client, addedEmojiRaw, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.GUILD_EMOJI_CREATE, addedEmoji); @@ -842,7 +842,7 @@ class EventHandler { const correspondingNewEmoji = new Emoji( this.#_client, correspondingNewEmojiRaw, - { guild_id: data.guild_id }, + { guildId: data.guild_id }, ); const differences = deepCompare( @@ -933,7 +933,7 @@ class EventHandler { const finalData = data; finalData.emoji = new Emoji(this.#_client, data.emoji, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.MESSAGE_REACTION_ADD, finalData); @@ -962,7 +962,7 @@ class EventHandler { const finalData = data; finalData.emoji = new Emoji(this.#_client, data.emoji, { - guild_id: data.guild_id, + guildId: data.guild_id, }); this.#_client.emit(EVENTS.MESSAGE_REACTION_REMOVE, finalData); diff --git a/src/managers/ChannelMessageManager.js b/src/managers/ChannelMessageManager.js index a37ef901..9d34ec85 100644 --- a/src/managers/ChannelMessageManager.js +++ b/src/managers/ChannelMessageManager.js @@ -111,8 +111,8 @@ class ChannelMessageManager extends BaseCacheManager { for (let i = 0; i < data.length; i++) messages.push( new Message(this.#_client, data[i], { - channel_id: data[i].channel_id, - guild_id: this.#channel.guild.id, + channelId: data[i].channel_id, + guildId: this.#channel.guild.id, }), ); return messages; @@ -248,7 +248,7 @@ class ChannelMessageManager extends BaseCacheManager { return new Message(client, data, { channelId, - guild_id: guildId, + guildId, }); } @@ -345,8 +345,8 @@ class ChannelMessageManager extends BaseCacheManager { for (let i = 0; i < data.length; i++) messages.push( new Message(client, data[i], { - channel_id: data[i].channel_id, - guild_id: guildId, + channelId: data[i].channel_id, + guildId, }), ); return messages; diff --git a/src/managers/GuildEmojisManager.js b/src/managers/GuildEmojisManager.js index 2192f5cb..7f65e27c 100644 --- a/src/managers/GuildEmojisManager.js +++ b/src/managers/GuildEmojisManager.js @@ -51,7 +51,7 @@ class GuildEmojisManager extends BaseCacheManager { emoji_id, ]); - return new Emoji(this.#_client, data, { guild_id: this.#guild.id }); + return new Emoji(this.#_client, data, { guildId: this.#guild.id }); } /** diff --git a/src/managers/GuildInviteManager.js b/src/managers/GuildInviteManager.js index 3c5a1a8c..e50321c4 100644 --- a/src/managers/GuildInviteManager.js +++ b/src/managers/GuildInviteManager.js @@ -56,7 +56,7 @@ class GuildInviteManager extends BaseCacheManager { this.clear(); return data.map( - (raw) => new Invite(this.#_client, raw, { guild_id: this.#guild.id }), + (raw) => new Invite(this.#_client, raw, { guildId: this.#guild.id }), ); } diff --git a/src/managers/GuildMemberManager.js b/src/managers/GuildMemberManager.js index 4acad99b..d1967cad 100644 --- a/src/managers/GuildMemberManager.js +++ b/src/managers/GuildMemberManager.js @@ -88,8 +88,8 @@ class GuildMemberManager extends BaseCacheManager { for (let i = 0; i < data.length; i++) members.push( new Member(this.#_client, data[i], { - user_id: data[i].user.id, - guild_id: this.#guild.id, + userId: data[i].user.id, + guildId: this.#guild.id, user: data[i].user, }), ); @@ -179,6 +179,8 @@ class GuildMemberManager extends BaseCacheManager { * @static */ static async search(client, guildId, query) { + if (!(client instanceof Client)) + throw new TypeError("GLUON: Client must be a Client instance."); if (typeof guildId !== "string") throw new TypeError("GLUON: Guild ID is not a string."); if (typeof query !== "string") @@ -201,8 +203,8 @@ class GuildMemberManager extends BaseCacheManager { for (let i = 0; i < data.length; i++) members.push( new Member(client, data[i], { - user_id: data[i].user.id, - guild_id: guildId.toString(), + userId: data[i].user.id, + guildId, user: data[i].user, }), ); diff --git a/src/managers/GuildRoleManager.js b/src/managers/GuildRoleManager.js index a668f194..86012bbd 100644 --- a/src/managers/GuildRoleManager.js +++ b/src/managers/GuildRoleManager.js @@ -54,7 +54,7 @@ class GuildRoleManager extends BaseCacheManager { let matchedRole; for (let i = 0; i < data.length; i++) { const role = new Role(this.#_client, data[i], { - guild_id: this.#guild.id, + guildId: this.#guild.id, }); if (role.id == role_id) matchedRole = role; } @@ -136,8 +136,6 @@ class GuildRoleManager extends BaseCacheManager { if (typeof roleId !== "undefined" && typeof roleId !== "string") throw new TypeError("GLUON: Role ID is not a string."); - const guild = client.guilds.get(guildId); - if (roleId) { const cachedRole = GuildRoleManager.getRole(client, guildId, roleId); if (cachedRole) return cachedRole; @@ -151,12 +149,11 @@ class GuildRoleManager extends BaseCacheManager { const data = await client.request.makeRequest("getRoles", [guildId]); - if (!roleId) - return data.map((role) => new Role(client, role, { guild_id: guildId })); + if (!roleId) return data.map((role) => new Role(client, role, { guildId })); let matchedRole; for (let i = 0; i < data.length; i++) { - const role = new Role(client, data[i], { guild_id: guildId }); + const role = new Role(client, data[i], { guildId }); if (role.id === roleId) matchedRole = role; } diff --git a/src/managers/GuildScheduledEventManager.js b/src/managers/GuildScheduledEventManager.js index 25693196..11b450f9 100644 --- a/src/managers/GuildScheduledEventManager.js +++ b/src/managers/GuildScheduledEventManager.js @@ -41,7 +41,7 @@ class GuildScheduledEventManager extends BaseCacheManager { for (let i = 0; i < data.length; i++) eventsList.push( new ScheduledEvent(this.#_client, data[i], { - guild_id: this.#guild.id, + guildId: this.#guild.id, }), ); @@ -70,7 +70,7 @@ class GuildScheduledEventManager extends BaseCacheManager { ); return new ScheduledEvent(this.#_client, data, { - guild_id: this.#guild.id, + guildId: this.#guild.id, }); } diff --git a/src/managers/MessageReactionManager.js b/src/managers/MessageReactionManager.js index 5e26b1a5..46930da7 100644 --- a/src/managers/MessageReactionManager.js +++ b/src/managers/MessageReactionManager.js @@ -40,7 +40,7 @@ class MessageReactionManager { this.#cache[messageReaction] = new Reaction( this.#_client, messageReactionValue, - { guild_id: this.#guild.id }, + { guildId: this.#guild.id }, ); } @@ -65,7 +65,7 @@ class MessageReactionManager { if (!this.#cache[emoji]) this.#cache[emoji] = new Reaction(this.#_client, data, { - guild_id: this.#guild.id, + guildId: this.#guild.id, }); this.#cache[emoji]._addReactor(user_id); diff --git a/src/structures/Attachment.js b/src/structures/Attachment.js index e7492b52..e2c50906 100644 --- a/src/structures/Attachment.js +++ b/src/structures/Attachment.js @@ -18,7 +18,7 @@ class Attachment { * @param {Client} client The client instance. * @param {Object} data Attachment data from Discord. */ - constructor(client, data, { channel_id } = {}) { + constructor(client, data, { channelId } = {}) { /** * The client instance. * @type {Client} @@ -66,7 +66,7 @@ class Attachment { * @type {BigInt?} * @private */ - if (channel_id) this.#_channel_id = BigInt(channel_id); + if (channelId) this.#_channel_id = BigInt(channelId); } /** diff --git a/src/structures/AuditLog.js b/src/structures/AuditLog.js index 5a694e9a..1a99647e 100644 --- a/src/structures/AuditLog.js +++ b/src/structures/AuditLog.js @@ -31,7 +31,7 @@ class AuditLog { * @param {Object} data Audit log data from Discord. * @param {Array} users Resolved users who are involved with the audit log entries. */ - constructor(client, data, { users, guild_id } = {}) { + constructor(client, data, { users, guildId } = {}) { /** * The client instance. * @type {Client} @@ -51,7 +51,7 @@ class AuditLog { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The type of action that occurred. diff --git a/src/structures/ButtonClick.js b/src/structures/ButtonClick.js index 5bd93ca0..b338d97c 100644 --- a/src/structures/ButtonClick.js +++ b/src/structures/ButtonClick.js @@ -17,7 +17,7 @@ class ButtonClick extends Interaction { * @param {Client} client The client instance. * @param {Object} data The interaction data from Discord. */ - constructor(client, data, { guild_id, channel_id } = {}) { + constructor(client, data, { guildId, channelId } = {}) { super(client, data); this.#_client = client; @@ -35,8 +35,8 @@ class ButtonClick extends Interaction { * @private */ this.#message = new Message(this.#_client, data.message, { - channel_id: channel_id, - guild_id: guild_id, + channelId, + guildId, }); } diff --git a/src/structures/CategoryChannel.js b/src/structures/CategoryChannel.js index 9fba640b..a04bcea3 100644 --- a/src/structures/CategoryChannel.js +++ b/src/structures/CategoryChannel.js @@ -13,11 +13,7 @@ class CategoryChannel { #_attributes; #permission_overwrites; #_cacheOptions; - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -37,7 +33,7 @@ class CategoryChannel { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The type of channel. diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 12dd1bc5..f19e7a43 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -36,7 +36,7 @@ class Channel { * @param {String} guild_id The ID of the guild that this channel belongs to. * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure} */ - constructor(client, data, { guild_id } = {}) { + constructor(client, data, { guildId } = {}) { /** * The client instance. * @type {Client} @@ -56,7 +56,7 @@ class Channel { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The type of channel. diff --git a/src/structures/Emoji.js b/src/structures/Emoji.js index 2d7dc6b4..75bfd419 100644 --- a/src/structures/Emoji.js +++ b/src/structures/Emoji.js @@ -20,11 +20,7 @@ class Emoji { * @param {String} guild_id The id of the guild that the emoji belongs to. * @param {Boolean?} nocache Whether this emoji should be cached or not. */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -72,7 +68,7 @@ class Emoji { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); if ( nocache === false && @@ -82,7 +78,7 @@ class Emoji { ) && this.id ) - this.#_client.guilds.get(guild_id)?.emojis.set(data.id, this); + this.#_client.guilds.get(guildId)?.emojis.set(data.id, this); } /** diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d4add078..6ef084b4 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -461,8 +461,8 @@ class Guild { ) for (let i = 0; i < data.members.length; i++) new Member(this.#_client, data.members[i], { - user_id: data.members[i].user.id, - guild_id: data.id, + userId: data.members[i].user.id, + guildId: data.id, user: data.members[i].user, nocache, }); @@ -482,7 +482,7 @@ class Guild { ) for (let i = 0; i < data.threads.length; i++) new Thread(this.#_client, data.threads[i], { - guild_id: data.id, + guildId: data.id, nocache, }); @@ -495,7 +495,7 @@ class Guild { ) for (let i = 0; i < data.voice_states.length; i++) new VoiceState(this.#_client, data.voice_states[i], { - guild_id: data.id, + guildId: data.id, nocache, }); @@ -504,7 +504,7 @@ class Guild { Role.shouldCache(this.#_client._cacheOptions, this._cacheOptions) === true ) for (let i = 0; i < data.roles.length; i++) - new Role(this.#_client, data.roles[i], { guild_id: data.id, nocache }); + new Role(this.#_client, data.roles[i], { guildId: data.id, nocache }); if ( data.emojis && @@ -513,7 +513,7 @@ class Guild { ) for (let i = 0; i < data.emojis.length; i++) new Emoji(this.#_client, data.emojis[i], { - guild_id: data.id, + guildId: data.id, nocache, }); @@ -524,7 +524,7 @@ class Guild { ) for (let i = 0; i < data.invites.length; i++) new Invite(this.#_client, data.invites[i], { - guild_id: data.id, + guildId: data.id, nocache, }); } @@ -1269,7 +1269,7 @@ class Guild { (e) => new AuditLog(this.#_client, e, { users: data.users, - guild_id: this.id, + guildId: this.id, }), ); } diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 68c973a8..b0b6f4f2 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -67,8 +67,8 @@ class Interaction { * @private */ this.#member = new Member(this.#_client, data.member, { - user_id: data.member.user.id, - guild_id: data.guild_id, + userId: data.member.user.id, + guildId: data.guild_id, }); /** diff --git a/src/structures/Invite.js b/src/structures/Invite.js index a41212f8..9a7ac6d1 100644 --- a/src/structures/Invite.js +++ b/src/structures/Invite.js @@ -24,11 +24,7 @@ class Invite { * @param {Boolean?} nocache Whether this invite should be cached or not. * @see {@link https://discord.com/developers/docs/resources/invite#invite-object-invite-structure} */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -41,7 +37,7 @@ class Invite { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The code for the invite. diff --git a/src/structures/Member.js b/src/structures/Member.js index 955937ab..79c13333 100644 --- a/src/structures/Member.js +++ b/src/structures/Member.js @@ -45,7 +45,7 @@ class Member { constructor( client, data, - { user_id, guild_id, user, nocache = false } = { + { userId, guildId, user, nocache = false } = { nocache: false, }, ) { @@ -61,16 +61,16 @@ class Member { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); - const existing = this.guild?.members.get(user_id) || null; + const existing = this.guild?.members.get(userId) || null; /** * The id of the member. * @type {BigInt} * @private */ - this.#_id = BigInt(user_id); + this.#_id = BigInt(userId); if (data.user) /** @@ -81,7 +81,7 @@ class Member { this.#user = new User(this.#_client, data.user, { nocache }); else if (existing?.user) this.#user = existing.user; else if (user) this.#user = user; - else this.#user = this.#_client.users.get(user_id) || null; + else this.#user = this.#_client.users.get(userId) || null; if (data.nick !== undefined) /** @@ -162,7 +162,7 @@ class Member { ) { this.#_roles = []; for (let i = 0; i < data.roles.length; i++) - if (data.roles[i] != guild_id) this.#_roles.push(BigInt(data.roles[i])); + if (data.roles[i] != guildId) this.#_roles.push(BigInt(data.roles[i])); } if ( @@ -173,7 +173,7 @@ class Member { this.guild._cacheOptions, )) ) { - this.guild.members.set(user_id, this); + this.guild.members.set(userId, this); } } @@ -435,15 +435,15 @@ class Member { * @static * @method */ - static getAvatarUrl(id, guild_id, hash) { + static getAvatarUrl(id, guildId, hash) { if (typeof id !== "string") throw new TypeError("GLUON: Member id must be a string."); - if (typeof guild_id !== "string") + if (typeof guildId !== "string") throw new TypeError("GLUON: Guild id must be a string."); if (hash && typeof hash !== "string") throw new TypeError("GLUON: Member avatar hash must be a string."); return hash - ? `${CDN_BASE_URL}/guilds/${guild_id}/users/${id}/avatars/${hash}.${ + ? `${CDN_BASE_URL}/guilds/${guildId}/users/${id}/avatars/${hash}.${ hash.startsWith("a_") ? "gif" : "png" }` : null; @@ -653,8 +653,8 @@ class Member { if (typeof userId !== "string") throw new TypeError("GLUON: User ID must be a string."); return new Member(client, decryptStructure(data, userId, guildId), { - user_id: userId, - guild_id: guildId, + userId: userId, + guildId: guildId, }); } diff --git a/src/structures/Message.js b/src/structures/Message.js index 53e84606..b2b34901 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -62,7 +62,7 @@ class Message { constructor( client, data, - { channel_id, guild_id, nocache = false, ignoreExisting = false } = { + { channelId, guildId, nocache = false, ignoreExisting = false } = { nocache: false, ignoreExisting: false, }, @@ -79,14 +79,14 @@ class Message { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The id of the channel that this message belongs to. * @type {BigInt} * @private */ - this.#_channel_id = BigInt(channel_id); + this.#_channel_id = BigInt(channelId); const existing = ignoreExisting != true @@ -132,8 +132,8 @@ class Message { * @private */ this.#member = new Member(this.#_client, data.member, { - user_id: data.author.id, - guild_id, + userId: data.author.id, + guildId, user: new User(this.#_client, data.author), }); else if (data.author) @@ -151,7 +151,7 @@ class Message { for (let i = 0; i < data.attachments.length; i++) this.#attachments.push( new Attachment(this.#_client, data.attachments[i], { - channel_id: this.channelId, + channelId: this.channelId, }), ); else if (existing?.attachments) this.#attachments = existing.attachments; @@ -175,7 +175,7 @@ class Message { * @private */ if (data.poll) - this.#poll = new Poll(this.#_client, data.poll, { guild_id }); + this.#poll = new Poll(this.#_client, data.poll, { guildId }); else if ( this.#poll == undefined && existing && @@ -924,8 +924,8 @@ class Message { ); return new Message(client, data, { - channel_id: channelId, - guild_id: guildId, + channelId, + guildId, }); } @@ -988,8 +988,8 @@ class Message { ); return new Message(client, data, { - channel_id: channelId, - guild_id: guildId, + channelId, + guildId, }); } @@ -1041,7 +1041,7 @@ class Message { return new Message( client, decryptStructure(data, messageId, channelId, guildId), - { channel_id: channelId, guild_id: guildId }, + { channelId, guildId }, ); } diff --git a/src/structures/OptionSelect.js b/src/structures/OptionSelect.js index 9af94c8d..f3be20c8 100644 --- a/src/structures/OptionSelect.js +++ b/src/structures/OptionSelect.js @@ -18,7 +18,7 @@ class OptionSelect extends Interaction { * @param {Client} client The client instance. * @param {Object} data The interaction data from Discord. */ - constructor(client, data, { channel_id, guild_id }) { + constructor(client, data, { channelId, guildId }) { super(client, data); this.#_client = client; @@ -36,8 +36,8 @@ class OptionSelect extends Interaction { * @private */ this.#message = new Message(this.#_client, data.message, { - channel_id, - guild_id, + channelId, + guildId, }); /** diff --git a/src/structures/Poll.js b/src/structures/Poll.js index c2277564..6f0e5430 100644 --- a/src/structures/Poll.js +++ b/src/structures/Poll.js @@ -12,7 +12,7 @@ class Poll { #allow_multiselect; #layout_type; #results; - constructor(client, data, { guild_id } = {}) { + constructor(client, data, { guildId } = {}) { /** * The client instance. * @type {Client} @@ -25,7 +25,7 @@ class Poll { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The question of the poll. diff --git a/src/structures/Reaction.js b/src/structures/Reaction.js index 6f7d5a27..ba2e2dcd 100644 --- a/src/structures/Reaction.js +++ b/src/structures/Reaction.js @@ -19,7 +19,7 @@ class Reaction { * @param {String} guild_id The id of the guild that the reaction belongs to. * @see {@link https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure} */ - constructor(client, data, { guild_id } = {}) { + constructor(client, data, { guildId } = {}) { /** * The client instance. * @type {Client} @@ -32,7 +32,7 @@ class Reaction { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); if (data.emoji.mention) /** @@ -42,7 +42,7 @@ class Reaction { */ this.#emoji = data.emoji; else - this.#emoji = new Emoji(client, data.emoji, { guild_id, nocache: true }); + this.#emoji = new Emoji(client, data.emoji, { guildId, nocache: true }); /** * Users who reacted with this emoji. diff --git a/src/structures/Role.js b/src/structures/Role.js index d089def6..65c58bb8 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -25,11 +25,7 @@ class Role { * @param {Boolean?} nocache Whether this role should be cached or not. * @see {@link https://discord.com/developers/docs/topics/permissions#role-object-role-structure} */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -42,7 +38,7 @@ class Role { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); /** * The id of the role. diff --git a/src/structures/ScheduledEvent.js b/src/structures/ScheduledEvent.js index 9f82496a..b20b55de 100644 --- a/src/structures/ScheduledEvent.js +++ b/src/structures/ScheduledEvent.js @@ -27,11 +27,7 @@ class ScheduledEvent { * @param {Client} client The client instance. * @param {Object} data Scheduled event data from Discord. */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -51,7 +47,7 @@ class ScheduledEvent { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); // const existing = this.guild?.scheduledEvents.get(data.id) || null; diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 45312c8c..cee33d02 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -19,12 +19,8 @@ class TextChannel extends Channel { * @param {Boolean?} nocache Whether this channel should be cached or not. * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-example-guild-text-channel} */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { - super(client, data, { guild_id }); + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { + super(client, data, { guildId }); /** * The client instance. @@ -42,8 +38,8 @@ class TextChannel extends Channel { if (data.messages) for (let i = 0; i < data.messages.length; i++) new Message(this.#_client, data.messages[i], { - channel_id: this.id, - guild_id, + channelId: this.id, + guildId, }); } diff --git a/src/structures/Thread.js b/src/structures/Thread.js index ead3582c..1f5d7fce 100644 --- a/src/structures/Thread.js +++ b/src/structures/Thread.js @@ -21,12 +21,8 @@ class Thread extends Channel { * @param {Boolean?} nocache Whether this thread should be cached or not. * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-example-thread-channel} */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { - super(client, data, { guild_id }); + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { + super(client, data, { guildId }); /** * The client instance. diff --git a/src/structures/User.js b/src/structures/User.js index e87b7ddd..05f3993a 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -27,9 +27,8 @@ class User { constructor( client, data, - { nocache = false, noDbStore = false } = { + { nocache = false } = { nocache: false, - noDbStore: false, }, ) { /** diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index 48cba716..f56b4a78 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -19,12 +19,8 @@ class VoiceChannel extends Channel { * @param {String} guild_id The id of the guild that the voice channel belongs to. * @param {Boolean?} nocache Whether the voice channel should be cached. */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { - super(client, data, { guild_id }); + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { + super(client, data, { guildId }); /** * The client instance. @@ -74,8 +70,8 @@ class VoiceChannel extends Channel { if (data.messages) for (let i = 0; i < data.messages.length; i++) new Message(this.#_client, data.messages[i], { - channel_id: this.id, - guild_id, + channelId: this.id, + guildId, }); } diff --git a/src/structures/VoiceState.js b/src/structures/VoiceState.js index a6554df0..44fa85ad 100644 --- a/src/structures/VoiceState.js +++ b/src/structures/VoiceState.js @@ -23,11 +23,7 @@ class VoiceState { * @param {String} guild_id The id of the guild that the voice state belongs to. * @param {Boolean?} nocache Whether this voice state should be cached. */ - constructor( - client, - data, - { guild_id, nocache = false } = { nocache: false }, - ) { + constructor(client, data, { guildId, nocache = false } = { nocache: false }) { /** * The client instance. * @type {Client} @@ -40,7 +36,7 @@ class VoiceState { * @type {BigInt} * @private */ - this.#_guild_id = BigInt(guild_id); + this.#_guild_id = BigInt(guildId); if (this.guild) nocache = @@ -84,8 +80,8 @@ class VoiceState { * @private */ this.#member = new Member(this.#_client, data.member, { - user_id: data.user_id, - guild_id: data.guild_id, + userId: data.user_id, + guildId: data.guild_id, user: data.member.user, nocache, }); diff --git a/src/testData.js b/src/testData.js index bbb6ce99..9b5340ba 100644 --- a/src/testData.js +++ b/src/testData.js @@ -1,6 +1,7 @@ import Client from "./Client.js"; import { INTENTS, PERMISSIONS } from "./constants.js"; import BetterRequestHandler from "./rest/betterRequestHandler.js"; +import { Member, Message, Role, ScheduledEvent } from "./structures.js"; import CategoryChannel from "./structures/CategoryChannel.js"; import Guild from "./structures/Guild.js"; import TextChannel from "./structures/TextChannel.js"; @@ -1009,26 +1010,102 @@ export const TEST_GUILDS = { export const TEST_CHANNELS = { TEXT_CHANNEL_ALL_CACHES_ENABLED: (client) => { const channel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); return channel; }, TEXT_CHANNEL_2_ALL_CACHES_ENABLED: (client) => { const channel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL_2, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); return channel; }, VOICE_CHANNEL_ALL_CACHES_ENABLED: (client) => { const channel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); return channel; }, CATEGORY_CHANNEL_ALL_CACHES_ENABLED: (client) => { const channel = new CategoryChannel(client, TEST_DATA.CATEGORY_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); return channel; }, }; + +export const TEST_MEMBERS = { + CLIENT_MEMBER: (client) => { + const member = new Member(client, TEST_DATA.CLIENT_MEMBER, { + userId: TEST_DATA.CLIENT_MEMBER.user.id, + guildId: TEST_DATA.GUILD_ID, + }); + return member; + }, + THREAD_OWNER_MEMBER: (client) => { + const member = new Member(client, TEST_DATA.CLIENT_MEMBER, { + userId: TEST_DATA.THREAD.owner_id, + guildId: TEST_DATA.GUILD_ID, + }); + return member; + }, + GUILD_OWNER_MEMBER: (client) => { + const member = new Member(client, TEST_DATA.MEMBER, { + userId: TEST_DATA.GUILD.owner_id, + guildId: TEST_DATA.GUILD_ID, + }); + return member; + }, + GENERIC_MEMBER: (client) => { + const member = new Member(client, TEST_DATA.MEMBER, { + userId: TEST_DATA.MEMBER_ID, + guildId: TEST_DATA.GUILD_ID, + }); + return member; + }, + VOICE_STATE_MEMBER: (client) => { + const member = new Member(client, TEST_DATA.MEMBER, { + guildId: TEST_DATA.GUILD_ID, + userId: TEST_DATA.VOICE_STATE.user_id, + }); + return member; + }, +}; + +export const TEST_MESSAGES = { + GENERIC_MESSAGE: (client) => { + const message = new Message(client, TEST_DATA.MESSAGE, { + guildId: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + }); + return message; + }, +}; + +export const TEST_ROLES = { + GENERIC_ADMIN_ROLE: (client) => { + const role = new Role(client, TEST_DATA.ROLE_ADMIN, { + guildId: TEST_DATA.GUILD_ID, + }); + return role; + }, +}; + +export const TEST_SCHEDULED_EVENTS = { + GENERIC_SCHEDULED_EVENT: (client) => { + const scheduledEvent = new ScheduledEvent( + client, + TEST_DATA.SCHEDULED_EVENT, + { guildId: TEST_DATA.GUILD_ID }, + ); + return scheduledEvent; + }, + EXTERNAL_GENERIC_SCHEDULED_EVENT: (client) => { + const scheduledEvent = new ScheduledEvent( + client, + TEST_DATA.SCHEDULED_EVENT_EXTERNAL, + { guildId: TEST_DATA.GUILD_ID }, + ); + return scheduledEvent; + }, +}; diff --git a/src/util/gluon/cacheChannel.js b/src/util/gluon/cacheChannel.js index e1b155f7..8f372982 100644 --- a/src/util/gluon/cacheChannel.js +++ b/src/util/gluon/cacheChannel.js @@ -12,25 +12,25 @@ import VoiceChannel from "../../structures/VoiceChannel.js"; * @param {Boolean?} nocache Whether the channel should be cached. * @returns {VoiceChannel | Thread | TextChannel} */ -function cacheChannel(client, data, guild_id, nocache = false) { +function cacheChannel(client, data, guildId, nocache = false) { switch (data.type) { case CHANNEL_TYPES.GUILD_VOICE: case CHANNEL_TYPES.GUILD_STAGE_VOICE: { - return new VoiceChannel(client, data, { guild_id, nocache }); + return new VoiceChannel(client, data, { guildId, nocache }); } case CHANNEL_TYPES.GUILD_NEWS_THREAD: case CHANNEL_TYPES.GUILD_PUBLIC_THREAD: case CHANNEL_TYPES.GUILD_PRIVATE_THREAD: { - return new Thread(client, data, { guild_id, nocache }); + return new Thread(client, data, { guildId, nocache }); } case CHANNEL_TYPES.GUILD_CATEGORY: { - return new CategoryChannel(client, data, { guild_id, nocache }); + return new CategoryChannel(client, data, { guildId, nocache }); } default: { - return new TextChannel(client, data, { guild_id, nocache }); + return new TextChannel(client, data, { guildId, nocache }); } } } diff --git a/test/structures/Attachment.js b/test/structures/Attachment.js index 0db03f94..191bc943 100644 --- a/test/structures/Attachment.js +++ b/test/structures/Attachment.js @@ -15,7 +15,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment).to.have.property("id"); expect(attachment).to.have.property("name"); @@ -31,7 +31,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment.id).to.equal(TEST_DATA.ATTACHMENT.id); }); @@ -42,7 +42,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment.name).to.equal(TEST_DATA.ATTACHMENT.filename); }); @@ -53,7 +53,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment.size).to.equal(TEST_DATA.ATTACHMENT.size); }); @@ -64,7 +64,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(`${attachment.url}&`).to.equal(TEST_DATA.ATTACHMENT.url); }); @@ -75,7 +75,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment.toJSON()).to.deep.equal({ id: TEST_DATA.ATTACHMENT.id, @@ -88,7 +88,7 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(attachment.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ id: TEST_DATA.ATTACHMENT.id, @@ -119,10 +119,10 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); const rebundled = new Attachment(client, attachment.toJSON(), { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(rebundled.id).to.equal(attachment.id); expect(rebundled.name).to.equal(attachment.name); @@ -134,13 +134,13 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); const rebundled = new Attachment( client, attachment.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }, ); expect(rebundled.id).to.equal(attachment.id); @@ -153,13 +153,13 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); const rebundled = new Attachment( client, attachment.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }, ); expect(rebundled.id).to.equal(attachment.id); @@ -170,13 +170,13 @@ describe("Attachment", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const attachment = new Attachment(client, TEST_DATA.ATTACHMENT, { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }); const rebundled = new Attachment( client, attachment.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, + channelId: TEST_DATA.CHANNEL_ID, }, ); expect(rebundled.id).to.equal(attachment.id); diff --git a/test/structures/AuditLog.js b/test/structures/AuditLog.js index bb15ff67..fe5902d6 100644 --- a/test/structures/AuditLog.js +++ b/test/structures/AuditLog.js @@ -14,7 +14,7 @@ describe("AuditLog", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog).to.have.property("id"); expect(auditLog).to.have.property("guildId"); @@ -40,7 +40,7 @@ describe("AuditLog", function () { it("should have the correct id", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.id).to.equal(TEST_DATA.AUDIT_LOG.id); }); @@ -50,7 +50,7 @@ describe("AuditLog", function () { it("should have the correct actionType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.actionType).to.equal(TEST_DATA.AUDIT_LOG.action_type); }); @@ -60,7 +60,7 @@ describe("AuditLog", function () { it("should have the correct reason", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.reason).to.equal(TEST_DATA.AUDIT_LOG.reason); }); @@ -70,7 +70,7 @@ describe("AuditLog", function () { it("should have the correct targetId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.targetId).to.equal(TEST_DATA.AUDIT_LOG.target_id); }); @@ -80,7 +80,7 @@ describe("AuditLog", function () { it("should have the correct channelId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.channelId).to.equal( TEST_DATA.AUDIT_LOG.options.channel_id, @@ -92,7 +92,7 @@ describe("AuditLog", function () { it("should have the correct executorId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.executorId).to.equal(TEST_DATA.AUDIT_LOG.user_id); }); @@ -102,7 +102,7 @@ describe("AuditLog", function () { it("should have the correct count", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.count).to.equal(TEST_DATA.AUDIT_LOG.count); }); @@ -112,7 +112,7 @@ describe("AuditLog", function () { it("should have the correct deleteMemberDays", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.deleteMemberDays).to.equal( TEST_DATA.AUDIT_LOG.delete_member_days, @@ -124,7 +124,7 @@ describe("AuditLog", function () { it("should have the correct membersRemoved", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.membersRemoved).to.equal( TEST_DATA.AUDIT_LOG.members_removed, @@ -136,7 +136,7 @@ describe("AuditLog", function () { it("should have the correct specialId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.specialId).to.equal(TEST_DATA.AUDIT_LOG.options.id); }); @@ -146,7 +146,7 @@ describe("AuditLog", function () { it("should have the correct specialType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.specialType).to.equal(TEST_DATA.AUDIT_LOG.options.type); }); @@ -156,7 +156,7 @@ describe("AuditLog", function () { it("should have the correct status", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.status).to.equal(TEST_DATA.AUDIT_LOG.status); }); @@ -166,7 +166,7 @@ describe("AuditLog", function () { it("should have the correct changes", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.changes).to.equal(TEST_DATA.AUDIT_LOG.changes); }); @@ -176,7 +176,7 @@ describe("AuditLog", function () { it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.toString()).to.equal( ``, @@ -188,7 +188,7 @@ describe("AuditLog", function () { it("should return the correct JSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.toJSON()).to.deep.equal({ id: TEST_DATA.AUDIT_LOG.id, @@ -212,7 +212,7 @@ describe("AuditLog", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(auditLog.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ id: TEST_DATA.AUDIT_LOG.id, @@ -274,10 +274,10 @@ describe("AuditLog", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const auditLog = new AuditLog(client, TEST_DATA.AUDIT_LOG, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new AuditLog(client, auditLog.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(auditLog.id); expect(rebundled.actionType).to.equal(auditLog.actionType); diff --git a/test/structures/ButtonClick.js b/test/structures/ButtonClick.js index c9ba8cec..f7ec0979 100644 --- a/test/structures/ButtonClick.js +++ b/test/structures/ButtonClick.js @@ -20,8 +20,8 @@ describe("ButtonClick", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const buttonClick = new ButtonClick(client, TEST_DATA.BUTTON_CLICK, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(buttonClick).to.have.property("id"); expect(buttonClick).to.have.property("type"); @@ -46,8 +46,8 @@ describe("ButtonClick", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const buttonClick = new ButtonClick(client, TEST_DATA.BUTTON_CLICK, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(buttonClick.customId).to.equal(TEST_DATA.BUTTON_CLICK.custom_id); }); @@ -59,8 +59,8 @@ describe("ButtonClick", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const buttonClick = new ButtonClick(client, TEST_DATA.BUTTON_CLICK, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, }); expect(buttonClick.message.id).to.equal( TEST_DATA.BUTTON_CLICK.message.id, diff --git a/test/structures/CategoryChannel.js b/test/structures/CategoryChannel.js index 0a0e0427..b026a9dc 100644 --- a/test/structures/CategoryChannel.js +++ b/test/structures/CategoryChannel.js @@ -17,7 +17,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel).to.have.property("id"); expect(categoryChannel).to.have.property("name"); @@ -36,7 +36,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.name).to.equal(TEST_DATA.CATEGORY_CHANNEL.name); }); @@ -49,7 +49,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.type).to.equal(TEST_DATA.CATEGORY_CHANNEL.type); }); @@ -62,7 +62,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.nsfw).to.equal(TEST_DATA.CATEGORY_CHANNEL.nsfw); }); @@ -75,7 +75,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.mention).to.equal( `<#${TEST_DATA.CATEGORY_CHANNEL.id}>`, @@ -90,7 +90,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.permissionOverwrites[0].toJSON()).to.deep.equal({ id: TEST_DATA.CATEGORY_CHANNEL.permission_overwrites[0].id, @@ -108,7 +108,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.toString()).to.equal( ``, @@ -123,7 +123,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(categoryChannel.toJSON()).to.deep.equal({ id: TEST_DATA.CATEGORY_CHANNEL.id, @@ -149,7 +149,7 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect( categoryChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), @@ -213,10 +213,10 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); const rebundled = new CategoryChannel(client, categoryChannel.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(categoryChannel.id); expect(rebundled.name).to.equal(categoryChannel.name); @@ -232,13 +232,13 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); const rebundled = new CategoryChannel( client, categoryChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(categoryChannel.id); @@ -255,13 +255,13 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); const rebundled = new CategoryChannel( client, categoryChannel.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(categoryChannel.id); @@ -278,13 +278,13 @@ describe("CategoryChannel", function () { const categoryChannel = new CategoryChannel( client, TEST_DATA.CATEGORY_CHANNEL, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); const rebundled = new CategoryChannel( client, categoryChannel.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(categoryChannel.id); diff --git a/test/structures/Channel.js b/test/structures/Channel.js index 2db7ba1a..2125d3d3 100644 --- a/test/structures/Channel.js +++ b/test/structures/Channel.js @@ -6,6 +6,8 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, + TEST_ROLES, } from "../../src/testData.js"; import Guild from "../../src/structures/Guild.js"; import ChannelMessageManager from "../../src/managers/ChannelMessageManager.js"; @@ -26,7 +28,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel).to.have.property("id"); expect(channel).to.have.property("name"); @@ -53,7 +55,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.id).to.equal(TEST_DATA.TEXT_CHANNEL.id); }); @@ -64,7 +66,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.name).to.equal(TEST_DATA.TEXT_CHANNEL.name); }); @@ -75,7 +77,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.type).to.equal(TEST_DATA.TEXT_CHANNEL.type); }); @@ -86,7 +88,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.guildId).to.equal(TEST_DATA.TEXT_CHANNEL.guild_id); }); @@ -97,7 +99,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.mention).to.equal(`<#${TEST_DATA.TEXT_CHANNEL.id}>`); }); @@ -108,7 +110,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.guild).to.be.an.instanceOf(Guild); }); @@ -119,7 +121,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.parentId).to.equal(TEST_DATA.TEXT_CHANNEL.parent_id); }); @@ -140,7 +142,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.rateLimitPerUser).to.equal( TEST_DATA.TEXT_CHANNEL.rate_limit_per_user, @@ -153,7 +155,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.nsfw).to.equal(TEST_DATA.TEXT_CHANNEL.nsfw); }); @@ -164,7 +166,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.topic).to.equal(TEST_DATA.TEXT_CHANNEL.topic); }); @@ -175,7 +177,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel._cacheOptions).to.be.an.instanceOf(ChannelCacheOptions); }); @@ -186,7 +188,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.messages).to.be.an.instanceOf(ChannelMessageManager); }); @@ -197,7 +199,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(() => channel.checkPermission()).to.throw( TypeError, @@ -208,7 +210,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(() => channel.checkPermission(123)).to.throw( TypeError, @@ -219,15 +221,12 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); new Role(client, TEST_DATA.ROLE_OVERRIDES, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_OVERRIDES.id]; - const member = new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL_2, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.checkPermission(member)).to.equal( String( @@ -260,7 +259,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.toString()).to.equal( ``, @@ -273,7 +272,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.toJSON()).to.deep.equal({ id: TEST_DATA.TEXT_CHANNEL.id, @@ -291,7 +290,7 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 0, @@ -336,19 +335,16 @@ describe("Channel", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); expect(channel.send).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); guild.channels.set(TEST_DATA.TEXT_CHANNEL.id, channel); await expect(channel.send({ content: "test" })).to.be.rejectedWith( @@ -359,14 +355,11 @@ describe("Channel", function () { it("should throw an error if no parameters are passed", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send()).to.be.rejectedWith( Error, @@ -376,14 +369,11 @@ describe("Channel", function () { it("should throw an error if content is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ content: 123 })).to.be.rejectedWith( TypeError, @@ -393,14 +383,11 @@ describe("Channel", function () { it("should throw an error if suppressMentions is not a boolean", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect( channel.send({ content: "test", suppressMentions: 123 }), @@ -412,14 +399,11 @@ describe("Channel", function () { it("should throw an error if embeds is not an array", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ embeds: 123 })).to.be.rejectedWith( TypeError, @@ -429,14 +413,11 @@ describe("Channel", function () { it("should throw an error if embeds is not an array of embeds", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ embeds: ["test"] })).to.be.rejectedWith( TypeError, @@ -446,14 +427,11 @@ describe("Channel", function () { it("should throw an error if components is not an array", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ components: 123 })).to.be.rejectedWith( TypeError, @@ -463,14 +441,11 @@ describe("Channel", function () { it("should throw an error if components is not an array of components", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ components: ["test"] })).to.be.rejectedWith( TypeError, @@ -480,14 +455,11 @@ describe("Channel", function () { it("should throw an error if files is not an array", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ files: 123 })).to.be.rejectedWith( TypeError, @@ -497,14 +469,11 @@ describe("Channel", function () { it("should throw an error if files is not an array of files", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await expect(channel.send({ files: ["test"] })).to.be.rejectedWith( TypeError, @@ -516,14 +485,11 @@ describe("Channel", function () { const request = spy(client.request, "makeRequest"); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); await channel.send({ content: "test" }); expect(request).to.be.calledOnce; @@ -539,10 +505,10 @@ describe("Channel", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); const rebundled = new Channel(client, channel.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(channel.id); expect(rebundled.name).to.equal(channel.name); @@ -563,13 +529,13 @@ describe("Channel", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); const rebundled = new Channel( client, channel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(channel.id); @@ -591,13 +557,13 @@ describe("Channel", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); const rebundled = new Channel( client, channel.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(channel.id); @@ -619,13 +585,13 @@ describe("Channel", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); const channel = new Channel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.TEXT_CHANNEL.guild_id, + guildId: TEST_DATA.TEXT_CHANNEL.guild_id, }); const rebundled = new Channel( client, channel.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(channel.id); diff --git a/test/structures/Emoji.js b/test/structures/Emoji.js index e38aea1b..da851912 100644 --- a/test/structures/Emoji.js +++ b/test/structures/Emoji.js @@ -16,7 +16,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji).to.have.property("id"); expect(emoji).to.have.property("requireColons"); @@ -38,7 +38,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.id).to.equal(TEST_DATA.EMOJI.id); }); @@ -46,7 +46,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.id).to.equal(null); }); @@ -57,7 +57,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.name).to.equal("bitcoin"); }); @@ -65,7 +65,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.name).to.equal(TEST_DATA.STANDARD_EMOJI.name); }); @@ -76,7 +76,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.animated).to.equal(true); }); @@ -84,7 +84,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.animated).to.equal(false); }); @@ -133,7 +133,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toString()).to.be.a("string"); }); @@ -141,7 +141,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toString()).to.equal(""); }); @@ -149,7 +149,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toString()).to.equal( ``, @@ -162,7 +162,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toJSON()).to.be.an("object"); }); @@ -170,7 +170,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toJSON()).to.deep.equal({ animated: true, @@ -185,7 +185,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 13, @@ -210,7 +210,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toJSON()).to.deep.equal({ name: TEST_DATA.STANDARD_EMOJI.name, @@ -225,7 +225,7 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(emoji.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 9, @@ -252,10 +252,10 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Emoji(client, emoji.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.animated).to.equal(emoji.animated); expect(rebundled.available).to.equal(emoji.available); @@ -275,12 +275,12 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Emoji( client, emoji.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.animated).to.equal(emoji.animated); expect(rebundled.available).to.equal(emoji.available); @@ -299,12 +299,12 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Emoji( client, emoji.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.animated).to.equal(emoji.animated); expect(rebundled.available).to.equal(emoji.available); @@ -323,12 +323,12 @@ describe("Emoji", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const emoji = new Emoji(client, TEST_DATA.STANDARD_EMOJI, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Emoji( client, emoji.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.animated).to.equal(emoji.animated); expect(rebundled.available).to.equal(emoji.available); diff --git a/test/structures/Guild.js b/test/structures/Guild.js index bc00a8bf..b9de946d 100644 --- a/test/structures/Guild.js +++ b/test/structures/Guild.js @@ -5,6 +5,8 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, + TEST_ROLES, } from "../../src/testData.js"; import { Member, @@ -109,10 +111,7 @@ describe("Guild", function () { it("should have the correct owner", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); expect(guild.owner.id).to.equal(TEST_DATA.GUILD.owner_id); }); }); @@ -481,10 +480,7 @@ describe("Guild", function () { it("should return a promise", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); expect(guild.me()).to.be.a("promise"); }); }); @@ -502,10 +498,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.ban()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: BAN_MEMBERS", @@ -514,12 +507,9 @@ describe("Guild", function () { it("should throw an error if no user id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.ban()).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -528,12 +518,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.ban(TEST_DATA.MEMBER_ID, { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: INVALID_TYPE: reason"); @@ -541,12 +528,9 @@ describe("Guild", function () { it("should throw an error if seconds is provided but it is not a number", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.ban(TEST_DATA.MEMBER_ID, { seconds: "123" }), ).to.be.rejectedWith(TypeError, "GLUON: INVALID_TYPE: seconds"); @@ -554,12 +538,9 @@ describe("Guild", function () { it("should throw an error if seconds is provided but it is less than 0", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.ban(TEST_DATA.MEMBER_ID, { seconds: -1 }), ).to.be.rejectedWith(RangeError, "GLUON: VALUE_OUT_OF_RANGE: seconds"); @@ -567,12 +548,9 @@ describe("Guild", function () { it("should throw an error if seconds is provided but it is too large", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.ban(TEST_DATA.MEMBER_ID, { seconds: 8 * 24 * 60 * 60 }), ).to.be.rejectedWith(RangeError, "GLUON: VALUE_OUT_OF_RANGE: seconds"); @@ -580,12 +558,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is too long", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.ban(TEST_DATA.MEMBER_ID, { reason: "a".repeat(513) }), ).to.be.rejectedWith(RangeError, "GLUON: VALUE_OUT_OF_RANGE: reason"); @@ -593,35 +568,26 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.ban(TEST_DATA.MEMBER_ID)).to.not.be.rejected; }); it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.ban(TEST_DATA.MEMBER_ID, { reason: "test" })).to.not.be .rejected; }); it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.ban(TEST_DATA.MEMBER_ID, { seconds: 1 })).to.not.be .rejected; }); @@ -629,12 +595,9 @@ describe("Guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.ban(TEST_DATA.MEMBER_ID); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("putCreateGuildBan", [ @@ -660,10 +623,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.unban()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: BAN_MEMBERS", @@ -672,12 +632,9 @@ describe("Guild", function () { it("should throw an error if no user id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.unban()).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -686,12 +643,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.unban(TEST_DATA.MEMBER_ID, { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: INVALID_TYPE: reason"); @@ -699,12 +653,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is too long", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.unban(TEST_DATA.MEMBER_ID, { reason: "a".repeat(513) }), ).to.be.rejectedWith(RangeError, "GLUON: VALUE_OUT_OF_RANGE: reason"); @@ -712,23 +663,17 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.unban(TEST_DATA.MEMBER_ID)).to.not.be.rejected; }); it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.unban(TEST_DATA.MEMBER_ID, { reason: "test" })).to.not .be.rejected; }); @@ -736,12 +681,9 @@ describe("Guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.unban(TEST_DATA.MEMBER_ID); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("deleteRemoveGuildBan", [ @@ -767,10 +709,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.kick()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: KICK_MEMBERS", @@ -779,12 +718,9 @@ describe("Guild", function () { it("should throw an error if no user id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.kick()).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -793,12 +729,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.kick(TEST_DATA.MEMBER_ID, { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: INVALID_TYPE: reason"); @@ -806,12 +739,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is too long", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.kick(TEST_DATA.MEMBER_ID, { reason: "a".repeat(513) }), ).to.be.rejectedWith(RangeError, "GLUON: VALUE_OUT_OF_RANGE: reason"); @@ -819,23 +749,17 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.kick(TEST_DATA.MEMBER_ID)).to.not.be.rejected; }); it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.kick(TEST_DATA.MEMBER_ID, { reason: "test" })).to.not .be.rejected; }); @@ -843,12 +767,9 @@ describe("Guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.kick(TEST_DATA.MEMBER_ID); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("deleteGuildMember", [ @@ -874,10 +795,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.removeMemberRole()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MANAGE_ROLES", @@ -886,12 +804,9 @@ describe("Guild", function () { it("should throw an error if no user id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.removeMemberRole()).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -900,12 +815,9 @@ describe("Guild", function () { it("should throw an error if no role id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.removeMemberRole(TEST_DATA.MEMBER_ID), ).to.be.rejectedWith(TypeError, "GLUON: INVALID_TYPE: role_id"); @@ -913,12 +825,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.removeMemberRole(TEST_DATA.MEMBER_ID, TEST_DATA.ROLE_ADMIN.id, { reason: 123, @@ -928,12 +837,9 @@ describe("Guild", function () { it("should throw an error if a reason is provided but it is too long", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.removeMemberRole(TEST_DATA.MEMBER_ID, TEST_DATA.ROLE_ADMIN.id, { reason: "a".repeat(513), @@ -943,12 +849,9 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.removeMemberRole(TEST_DATA.MEMBER_ID, TEST_DATA.ROLE_ADMIN.id), ).to.not.be.rejected; @@ -956,12 +859,9 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.removeMemberRole(TEST_DATA.MEMBER_ID, TEST_DATA.ROLE_ADMIN.id, { reason: "test", @@ -972,12 +872,9 @@ describe("Guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.removeMemberRole( TEST_DATA.MEMBER_ID, TEST_DATA.ROLE_ADMIN.id, @@ -1007,10 +904,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: VIEW_AUDIT_LOG", @@ -1019,12 +913,9 @@ describe("Guild", function () { it("should throw an error if limit is provided but it is not a number", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ limit: "123" })).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: limit", @@ -1033,12 +924,9 @@ describe("Guild", function () { it("should throw an error if limit is provided but it is less than 1", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ limit: 0 })).to.be.rejectedWith( RangeError, "GLUON: VALUE_OUT_OF_RANGE: limit", @@ -1047,12 +935,9 @@ describe("Guild", function () { it("should throw an error if limit is provided but it is greater than 100", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ limit: 101 })).to.be.rejectedWith( RangeError, "GLUON: VALUE_OUT_OF_RANGE: limit", @@ -1061,12 +946,9 @@ describe("Guild", function () { it("should throw an error if type is provided but it is not a number", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ type: "123" })).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: type", @@ -1075,12 +957,9 @@ describe("Guild", function () { it("should throw an error if user id is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ user_id: 123 })).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -1089,12 +968,9 @@ describe("Guild", function () { it("should throw an error if before is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ user_id: 123 })).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -1103,12 +979,9 @@ describe("Guild", function () { it("should throw an error if after is provided but it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs({ user_id: 123 })).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -1117,23 +990,17 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchAuditLogs()).to.not.be.rejected; }); it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect( guild.fetchAuditLogs({ limit: 1, @@ -1148,12 +1015,9 @@ describe("Guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.fetchAuditLogs(); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("getGuildAuditLog", [ @@ -1178,10 +1042,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchInvites()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MANAGE_GUILD", @@ -1190,24 +1051,18 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchInvites()).to.not.be.rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.fetchInvites(); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("getGuildInvites", [ @@ -1229,10 +1084,7 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchChannels()).to.not.be.rejected; }); it("should call makeRequest with the correct arguments", async function () { @@ -1260,10 +1112,7 @@ describe("Guild", function () { it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchBan()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: BAN_MEMBERS", @@ -1272,12 +1121,9 @@ describe("Guild", function () { it("should throw an error if no user id is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchBan()).to.be.rejectedWith( TypeError, "GLUON: INVALID_TYPE: user_id", @@ -1286,24 +1132,18 @@ describe("Guild", function () { it("should not be rejected if the input is valid", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await expect(guild.fetchBan(TEST_DATA.MEMBER_ID)).to.not.be.rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const request = spy(client.request, "makeRequest"); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); await guild.fetchBan(TEST_DATA.MEMBER_ID); expect(request).to.be.calledOnce; expect(request).to.be.calledOnceWith("getGuildBan", [ @@ -1377,10 +1217,7 @@ describe("Guild", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); const rebundled = new Guild(client, guild.toJSON()); expect(rebundled.id).to.deep.equal(guild.id); expect(rebundled.name).to.deep.equal(guild.name); @@ -1416,10 +1253,7 @@ describe("Guild", function () { it("should rebundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); const rebundled = new Guild( client, guild.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), @@ -1458,10 +1292,7 @@ describe("Guild", function () { it("should rebundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); const rebundled = new Guild( client, guild.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), @@ -1500,10 +1331,7 @@ describe("Guild", function () { it("should rebundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.GUILD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GUILD_OWNER_MEMBER(client); const rebundled = new Guild( client, guild.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), diff --git a/test/structures/Invite.js b/test/structures/Invite.js index 6fd52e16..7f66f145 100644 --- a/test/structures/Invite.js +++ b/test/structures/Invite.js @@ -20,7 +20,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite).to.have.property("code"); expect(invite).to.have.property("guildId"); @@ -43,7 +43,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.code).to.equal(TEST_DATA.INVITE.code); }); @@ -55,7 +55,7 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.guildId).to.equal(TEST_DATA.INVITE.guild_id); }); @@ -66,7 +66,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.channelId).to.equal(TEST_DATA.INVITE.channel.id); }); @@ -77,7 +77,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.uses).to.equal(TEST_DATA.INVITE.uses); }); @@ -88,7 +88,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.expires).to.equal( (new Date(TEST_DATA.INVITE.expires_at).getTime() / 1000) | 0, @@ -101,7 +101,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.inviter.id).to.equal(TEST_DATA.INVITE.inviter.id); }); @@ -112,7 +112,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.id).to.equal(TEST_DATA.INVITE.code); }); @@ -123,7 +123,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.url).to.equal( `${INVITE_BASE_URL}/${TEST_DATA.INVITE.code}`, @@ -136,7 +136,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.maxUses).to.equal(TEST_DATA.INVITE.max_uses); }); @@ -147,7 +147,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.guildId).to.equal(TEST_DATA.INVITE.guild_id); }); @@ -158,7 +158,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.guild.id).to.equal(TEST_DATA.GUILD_ID); }); @@ -183,7 +183,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.toString()).to.be.a("string"); }); @@ -191,7 +191,7 @@ describe("Invite", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.toString()).to.equal(``); }); @@ -203,7 +203,7 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.toJSON()).to.deep.equal({ code: TEST_DATA.INVITE.code, @@ -239,7 +239,7 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(invite.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ code: TEST_DATA.INVITE.code, @@ -333,11 +333,11 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Invite(client, invite.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.code).to.equal(invite.code); @@ -357,14 +357,14 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Invite( client, invite.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); @@ -385,14 +385,14 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Invite( client, invite.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); @@ -413,14 +413,14 @@ describe("Invite", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const invite = new Invite(client, TEST_DATA.INVITE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Invite( client, invite.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); diff --git a/test/structures/Member.js b/test/structures/Member.js index 0e175dcd..0430b27a 100644 --- a/test/structures/Member.js +++ b/test/structures/Member.js @@ -1,6 +1,12 @@ import { expect } from "chai"; import { spy } from "sinon"; -import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS } from "../../src/testData.js"; +import { + TEST_CLIENTS, + TEST_DATA, + TEST_GUILDS, + TEST_MEMBERS, + TEST_ROLES, +} from "../../src/testData.js"; import { Member, Role } from "../../src/structures.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; @@ -15,10 +21,7 @@ describe("Member", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member).to.have.property("user"); expect(member).to.have.property("guildId"); expect(member).to.have.property("guild"); @@ -56,10 +59,7 @@ describe("Member", function () { it("should have the correct user", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.user).to.be.an("object"); }); }); @@ -68,10 +68,7 @@ describe("Member", function () { it("should have the correct guildId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.guildId).to.equal(TEST_DATA.GUILD_ID); }); }); @@ -80,10 +77,7 @@ describe("Member", function () { it("should have the correct joinedAt", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.joinedAt).to.equal( (new Date(TEST_DATA.MEMBER.joined_at).getTime() / 1000) | 0, ); @@ -94,10 +88,7 @@ describe("Member", function () { it("should have the correct id", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.id).to.equal(TEST_DATA.MEMBER_ID); }); }); @@ -106,23 +97,14 @@ describe("Member", function () { it("should have the correct addRole", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.addRole).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.addRole(TEST_DATA.ROLE_ID)).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MANAGE_ROLES", @@ -131,16 +113,10 @@ describe("Member", function () { it("should throw an error if the role is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.addRole(123)).to.be.rejectedWith( TypeError, "GLUON: Role ID is not a string.", @@ -149,16 +125,10 @@ describe("Member", function () { it("should throw an error if a reason is provided and it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect( member.addRole(TEST_DATA.ROLE_ID, { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Reason is not a string."); @@ -166,47 +136,29 @@ describe("Member", function () { it("should not throw an error if the input is correct", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.addRole(TEST_DATA.ROLE_ID)).to.not.be.rejected; }); it("should not throw an error if the input is correct and a reason is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.addRole(TEST_DATA.ROLE_ID, { reason: "testing" })).to .not.be.rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const request = spy(client.request, "makeRequest"); await member.addRole(TEST_DATA.ROLE_ID, { reason: "testing" }); expect(request).to.be.calledOnce; @@ -223,23 +175,14 @@ describe("Member", function () { it("should have the correct removeRole", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.removeRole).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.removeRole(TEST_DATA.ROLE_ID)).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MANAGE_ROLES", @@ -248,16 +191,10 @@ describe("Member", function () { it("should throw an error if the role is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.removeRole(123)).to.be.rejectedWith( TypeError, "GLUON: Role ID is not a string.", @@ -266,16 +203,10 @@ describe("Member", function () { it("should throw an error if a reason is provided and it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect( member.removeRole(TEST_DATA.ROLE_ID, { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Reason is not a string."); @@ -283,47 +214,29 @@ describe("Member", function () { it("should not throw an error if the input is correct", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.removeRole(TEST_DATA.ROLE_ID)).to.not.be.rejected; }); it("should not throw an error if the input is correct and a reason is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.removeRole(TEST_DATA.ROLE_ID, { reason: "testing" })) .to.not.be.rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const request = spy(client.request, "makeRequest"); await member.removeRole(TEST_DATA.ROLE_ID, { reason: "testing" }); expect(request).to.be.calledOnce; @@ -340,23 +253,14 @@ describe("Member", function () { it("should have the correct timeoutAdd", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.timeoutAdd).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const timeoutUntil = ((new Date().getTime() / 1000) | 0) + 3600; await expect(member.timeoutAdd(timeoutUntil)).to.be.rejectedWith( Error, @@ -366,16 +270,10 @@ describe("Member", function () { it("should throw an error if the timeoutUntil is not a number", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutAdd("testing")).to.be.rejectedWith( TypeError, "GLUON: Timeout until must be a UNIX timestamp.", @@ -384,16 +282,10 @@ describe("Member", function () { it("should throw an error if a reason is provided and it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutAdd(123, { reason: 123 })).to.be.rejectedWith( TypeError, "GLUON: Reason must be a string.", @@ -402,47 +294,29 @@ describe("Member", function () { it("should not throw an error if the input is correct", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutAdd(123)).to.not.be.rejected; }); it("should not throw an error if the input is correct and a reason is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutAdd(123, { reason: "testing" })).to.not.be .rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const request = spy(client.request, "makeRequest"); await member.timeoutAdd(123, { reason: "testing" }); expect(request).to.be.calledOnce; @@ -458,23 +332,14 @@ describe("Member", function () { it("should have the correct timeoutRemove", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.timeoutRemove).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutRemove(TEST_DATA.ROLE_ID)).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MODERATE_MEMBERS", @@ -483,16 +348,10 @@ describe("Member", function () { it("should throw an error if a reason is provided and it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutRemove({ reason: 123 })).to.be.rejectedWith( TypeError, "GLUON: Reason must be a string.", @@ -501,47 +360,29 @@ describe("Member", function () { it("should not throw an error if the input is correct", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutRemove()).to.not.be.rejected; }); it("should not throw an error if the input is correct and a reason is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.timeoutRemove({ reason: "testing" })).to.not.be .rejected; }); it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const request = spy(client.request, "makeRequest"); await member.timeoutRemove({ reason: "testing" }); expect(request).to.be.calledOnce; @@ -557,23 +398,14 @@ describe("Member", function () { it("should have the correct massUpdateRoles", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.massUpdateRoles).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect( member.massUpdateRoles([TEST_DATA.ROLE_ID]), ).to.be.rejectedWith(Error, "MISSING PERMISSIONS: MANAGE_ROLES"); @@ -581,16 +413,10 @@ describe("Member", function () { it("should throw an error if the roles is not an array", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.massUpdateRoles(123)).to.be.rejectedWith( TypeError, "GLUON: Roles must be an array of role ids.", @@ -599,16 +425,10 @@ describe("Member", function () { it("should throw an error if the roles contains a non-string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.massUpdateRoles([123])).to.be.rejectedWith( TypeError, "GLUON: Roles must be an array of role ids.", @@ -617,16 +437,10 @@ describe("Member", function () { it("should throw an error if a reason is provided and it is not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect( member.massUpdateRoles([TEST_DATA.ROLE_ID], { reason: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Reason must be a string."); @@ -634,32 +448,20 @@ describe("Member", function () { it("should not throw an error if the input is correct", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect(member.massUpdateRoles([TEST_DATA.ROLE_ID])).to.not.be .rejected; }); it("should not throw an error if the input is correct and a reason is provided", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); await expect( member.massUpdateRoles([TEST_DATA.ROLE_ID], { reason: "testing" }), ).to.not.be.rejected; @@ -667,16 +469,10 @@ describe("Member", function () { it("should call makeRequest with the correct arguments", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const request = spy(client.request, "makeRequest"); await member.massUpdateRoles([TEST_DATA.ROLE_ID], { reason: "testing" }); expect(request).to.be.calledOnce; @@ -692,10 +488,7 @@ describe("Member", function () { it("should have the correct toString", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.toString).to.be.a("function"); }); }); @@ -704,10 +497,7 @@ describe("Member", function () { it("should have the correct toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.toJSON()).to.deep.equal({ avatar: null, communication_disabled_until: @@ -731,10 +521,7 @@ describe("Member", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 0, avatar: null, @@ -800,10 +587,7 @@ describe("Member", function () { it("should have the correct nick", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.nick).to.equal(TEST_DATA.MEMBER.nick); }); }); @@ -812,10 +596,7 @@ describe("Member", function () { it("should have the correct roles", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.roles).to.be.an("array"); }); }); @@ -824,10 +605,7 @@ describe("Member", function () { it("should have the correct flags", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.flags).to.equal(TEST_DATA.MEMBER.flags); }); }); @@ -836,10 +614,7 @@ describe("Member", function () { it("should have the correct highestRolePosition", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.highestRolePosition).to.equal(0); }); }); @@ -848,10 +623,7 @@ describe("Member", function () { it("should have the correct rejoined", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.rejoined).to.equal(false); }); }); @@ -860,10 +632,7 @@ describe("Member", function () { it("should have the correct displayAvatarURL", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.displayAvatarURL).to.equal( "https://cdn.discordapp.com/embed/avatars/0.png", ); @@ -874,10 +643,7 @@ describe("Member", function () { it("should have the correct permissions", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); // 8 since the member is the owner expect(member.permissions).to.equal("8"); }); @@ -887,10 +653,7 @@ describe("Member", function () { it("should have the correct avatarIsAnimated", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.avatarIsAnimated).to.equal(false); }); }); @@ -899,10 +662,7 @@ describe("Member", function () { it("should have the correct mention", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.mention).to.equal(`<@${TEST_DATA.MEMBER_ID}>`); }); }); @@ -911,10 +671,7 @@ describe("Member", function () { it("should have the correct pending", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.pending).to.equal(TEST_DATA.MEMBER.pending); }); }); @@ -923,10 +680,7 @@ describe("Member", function () { it("should have the correct timeoutUntil", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.timeoutUntil).to.equal(null); }); }); @@ -935,10 +689,7 @@ describe("Member", function () { it("should have the correct guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.guild.id).to.equal(TEST_DATA.GUILD_ID); }); }); @@ -1002,10 +753,7 @@ describe("Member", function () { it("should return the correct hashName", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); expect(member.hashName).to.equal( "8aa59de8144e3679c9e2ec87d00e5644b7b2adca0dea60fc1a3dc2bd52907ecf2f09397765e4e5310e840556a4e62b6afa9b85708a2f4ea1120c25a1099105a5", ); @@ -1016,10 +764,7 @@ describe("Member", function () { it("should return the correct encrypted member", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const encrypted = member.encrypt(); expect(encrypted).to.equal( "GZhWQoPL07tKRkr0dMP66gDiDBe2GwslYJEWQJKeXa/sWfZq5VJOsNRitkJQvSR/prD8QHJqAhp889GoLQfSvEv0NXeiU8NTL4nYIKLIIDWrwVlhSXDIStVEGvqtoP0JFi9OHBujvqofe4hkn6SAjlYWgxeqRZj4gXAgFJ+mWWlX63X+4wUZeL8cy2r3eThvjKFmBzAMp3X2i1WGYSKUyaum/zHiu89K9IZ26ewOAgX6RHz3dNrQpE/APOGrAeBM0fa27jBFqW8YDnsgQhrm185GAt4ky12xqbWvJPu+EEA=", @@ -1066,13 +811,10 @@ describe("Member", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const rebundled = new Member(client, member.toJSON(), { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, + userId: TEST_DATA.MEMBER_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(member.id); expect(rebundled.user.id).to.equal(member.user.id); @@ -1096,16 +838,13 @@ describe("Member", function () { it("should rebundle correctly with custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const rebundled = new Member( client, member.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, + userId: TEST_DATA.MEMBER_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(member.id); @@ -1130,16 +869,13 @@ describe("Member", function () { it("should rebundle correctly with custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const rebundled = new Member( client, member.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, + userId: TEST_DATA.MEMBER_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(member.id); @@ -1164,16 +900,13 @@ describe("Member", function () { it("should rebundle correctly with custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const member = new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + const member = TEST_MEMBERS.GENERIC_MEMBER(client); const rebundled = new Member( client, member.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, + userId: TEST_DATA.MEMBER_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(member.id); diff --git a/test/structures/Message.js b/test/structures/Message.js index cc883ac5..e4992d0a 100644 --- a/test/structures/Message.js +++ b/test/structures/Message.js @@ -5,6 +5,9 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, + TEST_MESSAGES, + TEST_ROLES, } from "../../src/testData.js"; import FileUpload from "../../src/util/builder/fileUpload.js"; import MessageComponents from "../../src/util/builder/messageComponents.js"; @@ -32,10 +35,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message).to.have.property("id"); expect(message).to.have.property("type"); expect(message).to.have.property("guildId"); @@ -81,10 +81,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.id).to.equal(TEST_DATA.MESSAGE.id); }); }); @@ -94,10 +91,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.type).to.equal(TEST_DATA.MESSAGE.type); }); }); @@ -107,10 +101,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.guildId).to.equal(TEST_DATA.GUILD_ID); }); }); @@ -120,10 +111,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.guild).to.deep.equal(guild); expect(message.guild).to.be.an.instanceOf(Guild); }); @@ -134,10 +122,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.channelId).to.equal(TEST_DATA.CHANNEL_ID); }); }); @@ -147,10 +132,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.channel.id).to.equal(TEST_DATA.CHANNEL_ID); }); }); @@ -160,10 +142,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.author.id).to.equal(TEST_DATA.MESSAGE.author.id); }); }); @@ -173,10 +152,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.content).to.equal(TEST_DATA.MESSAGE.content); }); }); @@ -186,10 +162,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.timestamp).to.equal(1449504684); }); }); @@ -199,10 +172,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.editedTimestamp).to.equal(1640995200); }); }); @@ -212,10 +182,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.mentionEveryone).to.equal(true); }); }); @@ -225,10 +192,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.mentions).to.equal(true); }); }); @@ -238,10 +202,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.mentionRoles).to.equal(true); }); }); @@ -251,10 +212,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.attachments).to.deep.equal([{}]); }); }); @@ -264,10 +222,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.embeds).to.deep.equal([ { color: TEST_DATA.MESSAGE.embeds[0].color, @@ -304,10 +259,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.reference).to.deep.equal({ messageId: "123456339013345678", }); @@ -319,10 +271,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.poll).to.be.an.instanceOf(Poll); }); }); @@ -332,10 +281,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.reactions).to.be.an.instanceOf(MessageReactionManager); }); }); @@ -345,10 +291,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.pinned).to.equal(true); }); }); @@ -358,14 +301,8 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.member.id).to.equal(TEST_DATA.MEMBER_ID); }); }); @@ -375,10 +312,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.mirrored).to.equal(false); }); }); @@ -388,10 +322,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.webhookId).to.equal(TEST_DATA.MESSAGE.webhook_id); }); }); @@ -401,10 +332,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.stickerItems).to.deep.equal([{}]); }); }); @@ -414,10 +342,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.messageSnapshots).to.deep.equal( TEST_DATA.MESSAGE.message_snapshots, ); @@ -429,10 +354,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.url).to.equal( `https://discord.com/channels/${TEST_DATA.GUILD_ID}/${TEST_DATA.CHANNEL_ID}/${TEST_DATA.MESSAGE.id}`, ); @@ -473,24 +395,15 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.reply).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.reply({ content: "test" })).to.be.rejectedWith( Error, "MISSING PERMISSIONS: SEND_MESSAGES", @@ -500,16 +413,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.reply()).to.be.rejectedWith( Error, "GLUON: Must provide content, embeds, components or files", @@ -519,16 +426,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.reply({ content: {} })).to.be.rejectedWith( TypeError, "GLUON: Content must be a string", @@ -538,16 +439,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect( message.reply({ content: "test", embeds: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Embeds must be an array"); @@ -556,16 +451,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect( message.reply({ content: "test", components: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Components must be an array"); @@ -574,16 +463,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect( message.reply({ content: "test", files: 123 }), ).to.be.rejectedWith(TypeError, "GLUON: Files must be an array"); @@ -592,32 +475,20 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.reply({ content: "test" })).to.not.be.rejected; }); it("should not throw an error if embeds is provided as an array of embeds", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.reply({ content: "test", embeds: [new Embed()] })).to .not.be.rejected; }); @@ -625,16 +496,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const components = new MessageComponents(); await expect(message.reply({ content: "test", components })).to.not.be .rejected; @@ -643,16 +508,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const file = new FileUpload() .setName("test.txt") .setPath(path.join(process.cwd(), "media", "quark.png")); @@ -663,16 +522,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const request = spy(client.request, "makeRequest"); await message.reply({ content: "test" }); expect(request).to.be.calledOnce; @@ -688,24 +541,15 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.edit).to.be.a("function"); }); it("should throw an error if bot permissions are insufficient", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ content: "test" })).to.be.rejectedWith( Error, "MISSING PERMISSIONS: SEND_MESSAGES", @@ -715,16 +559,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit()).to.be.rejectedWith( Error, "GLUON: Must provide content, embeds, components or files", @@ -734,16 +572,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ content: {} })).to.be.rejectedWith( TypeError, "GLUON: Content must be a string", @@ -753,16 +585,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ embeds: 123 })).to.be.rejectedWith( TypeError, "GLUON: Embeds must be an array", @@ -772,16 +598,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ components: 123 })).to.be.rejectedWith( TypeError, "GLUON: Components must be an array", @@ -791,16 +611,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ files: 123 })).to.be.rejectedWith( TypeError, "GLUON: Files must be an array", @@ -810,48 +624,30 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ content: "test" })).to.not.be.rejected; }); it("should not throw an error if embeds is provided as an array of embeds", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); await expect(message.edit({ embeds: [new Embed()] })).to.not.be.rejected; }); it("should not throw an error if components is provided as a message components class", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const components = new MessageComponents(); await expect(message.edit({ components })).to.not.be.rejected; }); @@ -859,16 +655,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const file = new FileUpload() .setName("test.txt") .setPath(path.join(process.cwd(), "media", "quark.png")); @@ -878,16 +668,10 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const request = spy(client.request, "makeRequest"); await message.edit({ content: "test" }); expect(request).to.be.calledOnce; @@ -904,10 +688,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.hashName).to.equal( "f5c5c86b4cb6ccf0e4aadf5d80eecb8bc19f005225ae37c856f95b50b02bad4482cbff6a2ca6a0a411eec7cc82e9c1ac654cc9d44c2f1c87f07d90b88da025b8", ); @@ -919,10 +700,7 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const encrypted = message.encrypt(); expect(encrypted).to.equal( "D7VouuLdNv/GOhSZHlt6sW6b3/LIoNHYIMOjkFzFgpw10SAjFZ6eeQXF6/mxBxgG4zC1h1GwI5dvCFA3LLnQrqXB/ToylQte2qiNhwAZ5oKWFbrE8YYCjGMGfIRA9cwIENjWytyYmbcE529uleVWsj0yIl9rfzSHLE/LrslM9cpTOXYv3NBN50cKvYTDaeNfx1T2kFwlE3jlqjNxKBQYKGeyoB0wqvnrjyLgOxa4jhdPnb/95ZHUa30tGiwqbDW4Is0KOBdxePJ5NVxok9fGWFqaFPGG3bmY1Ln2Oz5qTAkPDsqlYFY0mna+gEsk0o1AggRJ6Bru4xHH1g09S7CPKHmD2DkbF/gVVm3HI5h7v4mPZfwAtFBXn6rCySl3QrQ+TaU9/pafwmkOaKIkQAkcC8I7q6O4C9EEalBBHheu1jFlLE2Y1Gz2SZRNjwopARIeCS7bT/03Llm1XVv8pVd60vicMkLw41yoTnlJsPgQ+RZ4Xwa5eW9aofk6U+yHGzyV+x8V57s4gIPpX7rcLBWXBk60El2amyJHWVsWf6DJfFyk6c52U8yHoK4HnlJL52Dqx7R6vYa1on2UzJcOVBh9UQHdXIiOCKAxq1+sn8iiX2KqGHXo/JhHnRkMTJOULeH3XEkGItaDe3y5zweHHIhj0W/dnHwUslv+pYcr9hR6kYBZVpYerHtQdCVuYdnNcyCBF+iwKgvoX+1AqyJsJlUT7/En5xXScnrZNxRjh/ZCdrRHLAOS19uQfzfNto39XaAtEWb8kdBQMpL1TRsj35E7YJCqgSMkRqsCjnva5E6qawcRU/RfxLNMikcO7Yyq3pqYA5Xy34xkLpCSgSBS1mGNt/maHyxOAVt2LVA74pb0cATC9GcB7irqj57ayTZ3msuyjbY613ArY+/0xfju+GHf2yQBASrLYa5LL3nmtoCzrsWQzbdLIdv+XdVckriqs4uNk1k7wvZs4mawJnNhhIeU2fxKxin99rHOU4exmbbUMVqeWoMb8BkgKLO6Cn1BUU6IPS4t8YY8n9Y34m4cRJ9k2pKXfjHGgbzWRAaTBxx7I0WMZFnX2oLSmaiv3mT8hcBhDWEMyHhYOrNGjLgY+sEJiK50POisCJNC0rsq7aNbNvP8r/wjjLyEwcdEsItbeKwZhYuoAcynWODHM6slOT+IPfXVhtSB85vK8JgYcrfK1r2aO16vf01c7ZHCMuthNsZ8U8xw9iLW/R7ouyH4zzM1DnVQ1QiiBdzCh6SKpSWsMOsQTLrLqrmRHoZR5zMw9ZbPaZgJ6y/pIEpXSHNJWMCNub3qg/VoYjrQmU7NnyIbLjW0ktwlrjIssd1QTJysv7kcAuj4dGRKs0V1Vw9D/aMgh6T6WggHyYxivWCa33pDeMf57HT7hy3lUYf44PL+5p4WMb7yxkhABhdDd3okOpZvD77o2XnHr8acOLA8xoYOSfFKmc0FTau8qrVN88R7bIe/X/VGGLut/G2gK0Ibt4i8eFNooN3pre/do5lrjYLtbCXg5Ycd5cyuYlRZ+vloBeP49Oy3V2BXDs5D57hb0u0BKv57PZMQB2DsuZJfn0lS9PExa3lYo01GCfmUHWikuvk0F5JH89pgz7RdbhXSTHZOcoiFSe9i3wwdFabvu76dh+vXuzPsymDljZeCQWAKHyMDq9z/0cSEI0k/wU3P6tCKJ4wM7DQauaKel/ZHkOS7M3tSo52+kiLGJkCY333x+H0ZUxeGMUjBaR1BSxJUZsxi6I/LXy6H7TFvmWUOPURn0+8KieVQbvDDaWey4c8UNWBb69icTmn4ITAJ9YtZ00G5vexkgOmhzYWWAUXhPxuQI2W37QHN7SQE9oiiUmgUx9X0huxr3W1h7FX8bZBVy/bosBSuUf/TgZqkWe4ZNMuXcuphAta7MWPtb1UNUhD7sDTxqlKXbEN3udo1yxsr7dfQSorV5aImh9domK+kjPCfaF0=", @@ -990,20 +768,14 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toString).to.be.a("function"); }); it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toString()).to.equal(``); }); }); @@ -1013,34 +785,22 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toJSON).to.be.a("function"); }); it("should return an object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toJSON()).to.be.an("object"); }); it("should return the correct object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toJSON()).to.deep.equal({ id: TEST_DATA.MESSAGE_ID, type: TEST_DATA.MESSAGE.type, @@ -1132,14 +892,8 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); expect(message.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 15, id: TEST_DATA.MESSAGE_ID, @@ -1399,17 +1153,11 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const rebundled = new Message(client, message.toJSON(), { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(message.id); expect(rebundled.type).to.equal(message.type); @@ -1450,20 +1198,14 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const rebundled = new Message( client, message.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(message.id); @@ -1505,20 +1247,14 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const rebundled = new Message( client, message.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(message.id); @@ -1560,20 +1296,14 @@ describe("Message", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); - const message = new Message(client, TEST_DATA.MESSAGE, { - guild_id: TEST_DATA.GUILD_ID, - channel_id: TEST_DATA.CHANNEL_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); + const message = TEST_MESSAGES.GENERIC_MESSAGE(client); const rebundled = new Message( client, message.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(message.id); diff --git a/test/structures/OptionSelect.js b/test/structures/OptionSelect.js index 5a23dba7..b4869893 100644 --- a/test/structures/OptionSelect.js +++ b/test/structures/OptionSelect.js @@ -21,8 +21,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect).to.have.property("id"); expect(optionSelect).to.have.property("type"); @@ -48,8 +48,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.customId).to.equal( TEST_DATA.OPTION_SELECT.data.custom_id, @@ -63,8 +63,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.message.id).to.equal( TEST_DATA.OPTION_SELECT.message.id, @@ -78,8 +78,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.values).to.deep.equal( TEST_DATA.OPTION_SELECT.data.values, @@ -93,8 +93,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.toString).to.be.a("function"); }); @@ -103,8 +103,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.toString()).to.equal( ``, @@ -118,8 +118,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.toJSON).to.be.a("function"); }); @@ -128,8 +128,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(optionSelect.toJSON()).to.deep.equal({ id: TEST_DATA.OPTION_SELECT.id, @@ -196,8 +196,8 @@ describe("OptionSelect", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const optionSelect = new OptionSelect(client, TEST_DATA.OPTION_SELECT, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, }); expect( optionSelect.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), diff --git a/test/structures/Poll.js b/test/structures/Poll.js index 73225bee..b7486e40 100644 --- a/test/structures/Poll.js +++ b/test/structures/Poll.js @@ -15,7 +15,7 @@ describe("Poll", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll).to.have.property("guildId"); expect(poll).to.have.property("guild"); @@ -35,7 +35,7 @@ describe("Poll", function () { it("should have the correct question", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.question).to.equal(TEST_DATA.POLL.question); }); @@ -45,7 +45,7 @@ describe("Poll", function () { it("should have the correct guildId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.guildId).to.equal(TEST_DATA.GUILD_ID); }); @@ -56,7 +56,7 @@ describe("Poll", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.guild.id).to.equal(TEST_DATA.GUILD_ID); expect(poll.guild).to.be.an.instanceOf(Guild); @@ -67,7 +67,7 @@ describe("Poll", function () { it("should have the correct answers", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.answers).to.deep.equal([ { @@ -82,7 +82,7 @@ describe("Poll", function () { it("should have the correct expiry", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.expiry).to.equal( (new Date(TEST_DATA.POLL.expiry).getTime() / 1000) | 0, @@ -94,7 +94,7 @@ describe("Poll", function () { it("should have the correct allowMultiselect", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.allowMultiselect).to.equal(TEST_DATA.POLL.allow_multiselect); }); @@ -104,7 +104,7 @@ describe("Poll", function () { it("should have the correct layoutType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.layoutType).to.equal("DEFAULT"); }); @@ -114,7 +114,7 @@ describe("Poll", function () { it("should have the correct rawLayoutType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.rawLayoutType).to.equal(TEST_DATA.POLL.layout_type); }); @@ -124,7 +124,7 @@ describe("Poll", function () { it("should have the correct results", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll._results).to.be.an.instanceOf(MessagePollManager); }); @@ -134,7 +134,7 @@ describe("Poll", function () { it("should return a string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(poll.toString()).to.be.a("string"); }); @@ -144,7 +144,7 @@ describe("Poll", function () { it("should return the correct JSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, @@ -183,7 +183,7 @@ describe("Poll", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, @@ -266,14 +266,14 @@ describe("Poll", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, TEST_DATA.POLL.answers[0].answer_id, ); const rebundled = new Poll(client, poll.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.rawLayoutType).to.equal(poll.rawLayoutType); expect(rebundled.layoutType).to.equal(poll.layoutType); @@ -287,7 +287,7 @@ describe("Poll", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, @@ -297,7 +297,7 @@ describe("Poll", function () { client, poll.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.rawLayoutType).to.equal(poll.rawLayoutType); @@ -313,7 +313,7 @@ describe("Poll", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, @@ -323,7 +323,7 @@ describe("Poll", function () { client, poll.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.rawLayoutType).to.equal(poll.rawLayoutType); @@ -339,7 +339,7 @@ describe("Poll", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const poll = new Poll(client, TEST_DATA.POLL, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); poll._results._addVote( TEST_DATA.CLIENT_USER.id, @@ -349,7 +349,7 @@ describe("Poll", function () { client, poll.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.rawLayoutType).to.equal(poll.rawLayoutType); diff --git a/test/structures/Reaction.js b/test/structures/Reaction.js index ba6bb4fa..b60c7a73 100644 --- a/test/structures/Reaction.js +++ b/test/structures/Reaction.js @@ -1,6 +1,11 @@ import { expect } from "chai"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; -import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS } from "../../src/testData.js"; +import { + TEST_CLIENTS, + TEST_DATA, + TEST_GUILDS, + TEST_MEMBERS, +} from "../../src/testData.js"; import { Reaction, Guild, Member, Emoji } from "../../src/structures.js"; describe("Reaction", function () { @@ -15,7 +20,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction).to.have.property("count"); expect(reaction).to.have.property("reacted"); @@ -36,7 +41,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor("123456"); reaction._addReactor("654321"); @@ -48,12 +53,9 @@ describe("Reaction", function () { it("should have the correct reacted", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.reacted.length).to.equal(1); @@ -66,12 +68,9 @@ describe("Reaction", function () { it("should have the correct reactedIds", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.reactedIds.length).to.equal(1); @@ -84,7 +83,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.guildId).to.equal(TEST_DATA.GUILD_ID); }); @@ -95,7 +94,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.guild).to.be.an.instanceOf(Guild); expect(reaction.guild.id).to.equal(TEST_DATA.GUILD_ID); @@ -107,7 +106,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.emoji).to.be.an.instanceOf(Emoji); }); @@ -117,12 +116,9 @@ describe("Reaction", function () { it("should have the correct initialReactor", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.initialReactor).to.be.a("string"); @@ -134,12 +130,9 @@ describe("Reaction", function () { it("should add a reactor to the reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.reacted.length).to.equal(1); @@ -153,12 +146,9 @@ describe("Reaction", function () { it("should remove a reactor from the reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.reacted.length).to.equal(1); @@ -174,7 +164,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.toString).to.be.a("function"); }); @@ -182,7 +172,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.toString()).to.equal( `>`, @@ -195,7 +185,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.toJSON).to.be.a("function"); }); @@ -203,7 +193,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.toJSON()).to.deep.equal({ @@ -222,7 +212,7 @@ describe("Reaction", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); expect(reaction.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ @@ -260,16 +250,13 @@ describe("Reaction", function () { context("check bundling", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); const rebundled = new Reaction(client, reaction.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(reaction.count).to.equal(rebundled.count); expect(reaction.guildId).to.equal(rebundled.guildId); @@ -281,19 +268,16 @@ describe("Reaction", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); const rebundled = new Reaction( client, reaction.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(reaction.count).to.equal(rebundled.count); @@ -308,19 +292,16 @@ describe("Reaction", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); const rebundled = new Reaction( client, reaction.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(reaction.count).to.equal(rebundled.count); @@ -335,19 +316,16 @@ describe("Reaction", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - user_id: TEST_DATA.MEMBER_ID, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.GENERIC_MEMBER(client); const reaction = new Reaction(client, TEST_DATA.REACTION, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); reaction._addReactor(TEST_DATA.MEMBER_ID); const rebundled = new Reaction( client, reaction.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(reaction.count).to.equal(rebundled.count); diff --git a/test/structures/Role.js b/test/structures/Role.js index ea0f910f..67fa69af 100644 --- a/test/structures/Role.js +++ b/test/structures/Role.js @@ -1,5 +1,10 @@ import { expect } from "chai"; -import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS } from "../../src/testData.js"; +import { + TEST_CLIENTS, + TEST_DATA, + TEST_GUILDS, + TEST_ROLES, +} from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { Role } from "../../src/structures.js"; @@ -14,9 +19,7 @@ describe("Role", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role).to.have.property("id"); expect(role).to.have.property("hoist"); expect(role).to.have.property("name"); @@ -39,9 +42,7 @@ describe("Role", function () { it("should have the correct name", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.name).to.equal(TEST_DATA.ROLE_ADMIN.name); }); }); @@ -50,9 +51,7 @@ describe("Role", function () { it("should have the correct color", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.color).to.equal(TEST_DATA.ROLE_ADMIN.color); }); }); @@ -61,9 +60,7 @@ describe("Role", function () { it("should have the correct position", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.position).to.equal(TEST_DATA.ROLE_ADMIN.position); }); }); @@ -72,9 +69,7 @@ describe("Role", function () { it("should have the correct mention", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.mention).to.equal(`<@&${TEST_DATA.ROLE_ID}>`); }); }); @@ -83,9 +78,7 @@ describe("Role", function () { it("should have the correct permissions", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.permissions).to.equal( String(TEST_DATA.ROLE_ADMIN.permissions), ); @@ -96,9 +89,7 @@ describe("Role", function () { it("should have the correct guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.guild.id).to.equal(guild.id); }); }); @@ -107,9 +98,7 @@ describe("Role", function () { it("should have the correct guildId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.guildId).to.equal(TEST_DATA.GUILD_ID); }); }); @@ -118,9 +107,7 @@ describe("Role", function () { it("should have the correct displayIconURL", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.displayIconURL).to.equal( `https://cdn.discordapp.com/role-icons/${TEST_DATA.ROLE_ID}/${TEST_DATA.ROLE_ADMIN.icon}.png`, ); @@ -131,9 +118,7 @@ describe("Role", function () { it("should have the correct tags", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.tags).to.deep.equal({ bot_id: "123456789012345678", integration_id: null, @@ -191,17 +176,13 @@ describe("Role", function () { it("should return a string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.toString()).to.be.a("string"); }); it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.toString()).to.equal(``); }); }); @@ -210,17 +191,13 @@ describe("Role", function () { it("should return a JSON object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.toJSON()).to.be.a("object"); }); it("should return the correct JSON object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.toJSON()).to.deep.equal({ hoist: TEST_DATA.ROLE_ADMIN.hoist, managed: TEST_DATA.ROLE_ADMIN.managed, @@ -241,9 +218,7 @@ describe("Role", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); expect(role.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 7, icon: TEST_DATA.ROLE_ADMIN.icon, @@ -295,11 +270,9 @@ describe("Role", function () { it("should return the correct bundle", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); const rebundled = new Role(client, role.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(role.id); expect(rebundled.name).to.equal(role.name); @@ -318,14 +291,12 @@ describe("Role", function () { it("should return the correct bundle with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); const rebundled = new Role( client, role.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(role.id); @@ -345,14 +316,12 @@ describe("Role", function () { it("should return the correct bundle with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); const rebundled = new Role( client, role.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(role.id); @@ -372,14 +341,12 @@ describe("Role", function () { it("should return the correct bundle with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const role = new Role(client, TEST_DATA.ROLE_ADMIN, { - guild_id: TEST_DATA.GUILD_ID, - }); + const role = TEST_ROLES.GENERIC_ADMIN_ROLE(client); const rebundled = new Role( client, role.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(role.id); diff --git a/test/structures/ScheduledEvent.js b/test/structures/ScheduledEvent.js index 9b03d1fd..bd4a004b 100644 --- a/test/structures/ScheduledEvent.js +++ b/test/structures/ScheduledEvent.js @@ -1,5 +1,10 @@ import { expect } from "chai"; -import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS } from "../../src/testData.js"; +import { + TEST_CLIENTS, + TEST_DATA, + TEST_GUILDS, + TEST_SCHEDULED_EVENTS, +} from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { ScheduledEvent, Guild, User } from "../../src/structures.js"; @@ -14,11 +19,8 @@ describe("ScheduledEvent", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent).to.have.property("id"); expect(scheduledEvent).to.have.property("guildId"); expect(scheduledEvent).to.have.property("scheduledStartTime"); @@ -33,11 +35,8 @@ describe("ScheduledEvent", function () { it("should have the correct id", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.id).to.equal(TEST_DATA.SCHEDULED_EVENT.id); }); }); @@ -46,11 +45,8 @@ describe("ScheduledEvent", function () { it("should have the correct guildId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.guildId).to.equal(TEST_DATA.GUILD_ID); }); }); @@ -59,11 +55,8 @@ describe("ScheduledEvent", function () { it("should have the correct guild", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.guild).to.be.an.instanceOf(Guild); }); }); @@ -72,11 +65,8 @@ describe("ScheduledEvent", function () { it("should have the correct name", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.name).to.equal(TEST_DATA.SCHEDULED_EVENT.name); }); }); @@ -85,11 +75,8 @@ describe("ScheduledEvent", function () { it("should have the correct creatorId", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.creatorId).to.equal( TEST_DATA.SCHEDULED_EVENT.creator_id, ); @@ -100,11 +87,8 @@ describe("ScheduledEvent", function () { it("should have the correct creator", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.creator).to.be.an.instanceOf(User); expect(scheduledEvent.creator.id).to.be.equal( TEST_DATA.SCHEDULED_EVENT.creator.id, @@ -116,11 +100,8 @@ describe("ScheduledEvent", function () { it("should have the correct displayImageURL", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.displayImageURL).to.equal( `https://cdn.discordapp.com/guild-events/123409989012345678/${TEST_DATA.SCHEDULED_EVENT.image}.png`, ); @@ -131,11 +112,8 @@ describe("ScheduledEvent", function () { it("should have the correct description", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.description).to.equal( TEST_DATA.SCHEDULED_EVENT.description, ); @@ -146,21 +124,15 @@ describe("ScheduledEvent", function () { it("should have the correct entityType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.entityType).to.equal("VOICE"); }); it("should have the correct entityType", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT_EXTERNAL, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.EXTERNAL_GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.entityType).to.equal("EXTERNAL"); }); }); @@ -169,11 +141,8 @@ describe("ScheduledEvent", function () { it("should have the correct status", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.status).to.equal("SCHEDULED"); }); }); @@ -182,11 +151,8 @@ describe("ScheduledEvent", function () { it("should have the correct scheduledStartTime", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.scheduledStartTime).to.equal( (new Date(TEST_DATA.SCHEDULED_EVENT.scheduled_start_time).getTime() / 1000) | @@ -199,11 +165,8 @@ describe("ScheduledEvent", function () { it("should have the correct scheduledEndTime", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.scheduledEndTime).to.equal( (new Date(TEST_DATA.SCHEDULED_EVENT.scheduled_end_time) / 1000) | 0, ); @@ -214,11 +177,8 @@ describe("ScheduledEvent", function () { it("should have the correct userCount", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.userCount).to.equal( TEST_DATA.SCHEDULED_EVENT.user_count, ); @@ -229,11 +189,8 @@ describe("ScheduledEvent", function () { it("should have the correct location", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT_EXTERNAL, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.EXTERNAL_GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.location).to.equal( TEST_DATA.SCHEDULED_EVENT_EXTERNAL.entity_metadata.location, ); @@ -271,21 +228,15 @@ describe("ScheduledEvent", function () { it("should return a string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.toString()).to.be.a("string"); }); it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.toString()).to.equal( ``, ); @@ -296,21 +247,15 @@ describe("ScheduledEvent", function () { it("should return an object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.toJSON()).to.be.a("object"); }); it("should return the correct object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect(scheduledEvent.toJSON()).to.deep.equal({ id: TEST_DATA.SCHEDULED_EVENT.id, creator: { @@ -347,11 +292,8 @@ describe("ScheduledEvent", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); expect( scheduledEvent.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), ).to.deep.equal({ @@ -461,13 +403,10 @@ describe("ScheduledEvent", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); const rebundled = new ScheduledEvent(client, scheduledEvent.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.creator).to.be.an.instanceOf(User); expect(scheduledEvent.creator.toJSON()).to.deep.equal( @@ -497,15 +436,12 @@ describe("ScheduledEvent", function () { it("should bundle correctly with custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); const rebundled = new ScheduledEvent( client, scheduledEvent.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.creator).to.be.an.instanceOf(User); expect(scheduledEvent.creator.toJSON()).to.deep.equal( @@ -534,15 +470,12 @@ describe("ScheduledEvent", function () { }); const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent( - client, - TEST_DATA.SCHEDULED_EVENT, - { guild_id: TEST_DATA.GUILD_ID }, - ); + const scheduledEvent = + TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); const rebundled = new ScheduledEvent( client, scheduledEvent.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.creator).to.be.an.instanceOf(User); expect(scheduledEvent.creator.toJSON()).to.deep.equal( @@ -569,13 +502,11 @@ describe("ScheduledEvent", function () { }); const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const scheduledEvent = new ScheduledEvent(client, TEST_DATA.SCHEDULED_EVENT, { - guild_id: TEST_DATA.GUILD_ID, - }); + const scheduledEvent = TEST_SCHEDULED_EVENTS.GENERIC_SCHEDULED_EVENT(client); const rebundled = new ScheduledEvent( client, scheduledEvent.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ); expect(rebundled.creator).to.be.an.instanceOf(User); expect(scheduledEvent.creator.toJSON()).to.deep.equal( diff --git a/test/structures/TextChannel.js b/test/structures/TextChannel.js index a455b6e2..70b16e60 100644 --- a/test/structures/TextChannel.js +++ b/test/structures/TextChannel.js @@ -5,6 +5,8 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, + TEST_ROLES, } from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { TextChannel, Member, Role } from "../../src/structures.js"; @@ -20,9 +22,7 @@ describe("TextChannel", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel).to.have.property("id"); expect(textChannel).to.have.property("name"); expect(textChannel).to.have.property("type"); @@ -47,21 +47,14 @@ describe("TextChannel", function () { it("should be a function", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.bulkDelete).to.be.a("function"); }); it("should return an error if the bot has insufficient permissions", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); await expect(textChannel.bulkDelete()).to.be.rejectedWith( Error, "MISSING PERMISSIONS: MANAGE_MESSAGES", @@ -70,15 +63,10 @@ describe("TextChannel", function () { it("should return an error if messages is not an array of strings", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); await expect(textChannel.bulkDelete(["1", 2])).to.be.rejectedWith( TypeError, "GLUON: Messages is not an array of strings.", @@ -87,15 +75,10 @@ describe("TextChannel", function () { it("should return an error if reason is provided and not a string", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); await expect( textChannel.bulkDelete(["1"], { reason: 1 }), ).to.be.rejectedWith(TypeError, "GLUON: Reason is not a string."); @@ -103,15 +86,10 @@ describe("TextChannel", function () { it("should call makeRequest with the correct parameters", async function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const request = spy(client.request, "makeRequest"); await textChannel.bulkDelete(["1", "2"]); expect(request).to.be.calledOnce; @@ -126,17 +104,13 @@ describe("TextChannel", function () { it("should return a string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.toString()).to.be.a("string"); }); it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.toString()).to.equal( ``, ); @@ -147,17 +121,13 @@ describe("TextChannel", function () { it("should return a JSON object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.toJSON()).to.be.a("object"); }); it("should return the correct JSON object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.toJSON()).to.deep.equal({ id: TEST_DATA.TEXT_CHANNEL.id, messages: [], @@ -173,9 +143,7 @@ describe("TextChannel", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); expect(textChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal( { _attributes: 0, @@ -224,21 +192,16 @@ describe("TextChannel", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new TextChannel(client, textChannel.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(textChannel.id); @@ -258,24 +221,19 @@ describe("TextChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new TextChannel( client, textChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); @@ -296,24 +254,19 @@ describe("TextChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new TextChannel( client, textChannel.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); @@ -334,24 +287,19 @@ describe("TextChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Role(client, TEST_DATA.ROLE_ADMIN, { guild_id: TEST_DATA.GUILD_ID }); + TEST_ROLES.GENERIC_ADMIN_ROLE(client); TEST_DATA.CLIENT_MEMBER.roles = [TEST_DATA.ROLE_ADMIN.id]; - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.CLIENT_MEMBER.user.id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.CLIENT_MEMBER(client); TEST_CHANNELS.CATEGORY_CHANNEL_ALL_CACHES_ENABLED(client); - const textChannel = new TextChannel(client, TEST_DATA.TEXT_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const textChannel = TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new TextChannel( client, textChannel.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); diff --git a/test/structures/Thread.js b/test/structures/Thread.js index f0c02a19..855fffbe 100644 --- a/test/structures/Thread.js +++ b/test/structures/Thread.js @@ -4,6 +4,7 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, } from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { Thread, Member } from "../../src/structures.js"; @@ -20,7 +21,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread).to.have.property("id"); expect(thread).to.have.property("ownerId"); @@ -37,7 +38,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.ownerId).to.equal(TEST_DATA.THREAD.owner_id); }); @@ -47,12 +48,9 @@ describe("Thread", function () { it("should have the correct owner", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.THREAD.owner_id, - }); + TEST_MEMBERS.THREAD_OWNER_MEMBER(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.owner.id).to.equal(TEST_DATA.THREAD.owner_id); }); @@ -63,7 +61,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.parentId).to.equal(TEST_DATA.THREAD.parent_id); }); @@ -74,7 +72,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); }); }); @@ -84,7 +82,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.toString()).to.be.a("string"); }); @@ -92,7 +90,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.toString()).to.equal(``); }); @@ -103,7 +101,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.toJSON()).to.be.an("object"); }); @@ -111,7 +109,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.toJSON()).to.deep.equal({ id: TEST_DATA.THREAD.id, @@ -130,7 +128,7 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(thread.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 0, @@ -178,15 +176,12 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.THREAD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.THREAD_OWNER_MEMBER(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Thread(client, thread.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(thread.id); expect(rebundled.name).to.equal(thread.name); @@ -204,18 +199,15 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.THREAD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.THREAD_OWNER_MEMBER(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Thread( client, thread.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(thread.id); @@ -233,18 +225,15 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.THREAD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.THREAD_OWNER_MEMBER(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Thread( client, thread.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(thread.id); @@ -262,18 +251,15 @@ describe("Thread", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.CLIENT_MEMBER, { - user_id: TEST_DATA.THREAD.owner_id, - guild_id: TEST_DATA.GUILD_ID, - }); + TEST_MEMBERS.THREAD_OWNER_MEMBER(client); const thread = new Thread(client, TEST_DATA.THREAD, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new Thread( client, thread.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(thread.id); diff --git a/test/structures/VoiceChannel.js b/test/structures/VoiceChannel.js index 8ea651f7..9120c37d 100644 --- a/test/structures/VoiceChannel.js +++ b/test/structures/VoiceChannel.js @@ -1,5 +1,10 @@ import { expect } from "chai"; -import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS } from "../../src/testData.js"; +import { + TEST_CHANNELS, + TEST_CLIENTS, + TEST_DATA, + TEST_GUILDS, +} from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { VoiceChannel } from "../../src/structures.js"; @@ -14,9 +19,8 @@ describe("VoiceChannel", function () { it("should have the correct structure", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel).to.have.property("id"); expect(voiceChannel).to.have.property("name"); expect(voiceChannel).to.have.property("type"); @@ -43,9 +47,8 @@ describe("VoiceChannel", function () { it("should have the correct bitrate", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.bitrate).to.equal(TEST_DATA.VOICE_CHANNEL.bitrate); }); }); @@ -54,9 +57,8 @@ describe("VoiceChannel", function () { it("should have the correct userLimit", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.userLimit).to.equal( TEST_DATA.VOICE_CHANNEL.user_limit, ); @@ -67,9 +69,8 @@ describe("VoiceChannel", function () { it("should have the correct rtcRegion", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.rtcRegion).to.equal( TEST_DATA.VOICE_CHANNEL.rtcRegion, ); @@ -80,18 +81,16 @@ describe("VoiceChannel", function () { it("should return a string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.toString()).to.be.a("string"); }); it("should return the correct string", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.toString()).to.equal( ``, ); @@ -102,18 +101,16 @@ describe("VoiceChannel", function () { it("should return an object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.toJSON()).to.be.a("object"); }); it("should return the correct object", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect(voiceChannel.toJSON()).to.deep.equal({ bitrate: TEST_DATA.VOICE_CHANNEL.bitrate, id: TEST_DATA.VOICE_CHANNEL.id, @@ -132,9 +129,8 @@ describe("VoiceChannel", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); expect( voiceChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), ).to.deep.equal({ @@ -192,11 +188,10 @@ describe("VoiceChannel", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new VoiceChannel(client, voiceChannel.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.id).to.equal(voiceChannel.id); expect(rebundled.name).to.equal(voiceChannel.name); @@ -209,14 +204,13 @@ describe("VoiceChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new VoiceChannel( client, voiceChannel.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(voiceChannel.id); @@ -230,14 +224,13 @@ describe("VoiceChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new VoiceChannel( client, voiceChannel.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(voiceChannel.id); @@ -251,14 +244,13 @@ describe("VoiceChannel", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - const voiceChannel = new VoiceChannel(client, TEST_DATA.VOICE_CHANNEL, { - guild_id: TEST_DATA.GUILD_ID, - }); + const voiceChannel = + TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const rebundled = new VoiceChannel( client, voiceChannel.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.id).to.equal(voiceChannel.id); diff --git a/test/structures/VoiceState.js b/test/structures/VoiceState.js index e8cb46e8..3ef28cb3 100644 --- a/test/structures/VoiceState.js +++ b/test/structures/VoiceState.js @@ -4,6 +4,7 @@ import { TEST_CLIENTS, TEST_DATA, TEST_GUILDS, + TEST_MEMBERS, } from "../../src/testData.js"; import { TO_JSON_TYPES_ENUM } from "../../src/constants.js"; import { VoiceState, VoiceChannel, Member } from "../../src/structures.js"; @@ -20,7 +21,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState).to.have.property("deaf"); expect(voiceState).to.have.property("mute"); @@ -47,7 +48,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.deaf).to.equal(TEST_DATA.VOICE_STATE.deaf); }); @@ -58,7 +59,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.mute).to.equal(TEST_DATA.VOICE_STATE.mute); }); @@ -69,7 +70,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.selfDeaf).to.equal(TEST_DATA.VOICE_STATE.self_deaf); }); @@ -80,7 +81,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.selfMute).to.equal(TEST_DATA.VOICE_STATE.self_mute); }); @@ -91,7 +92,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.selfStream).to.equal(TEST_DATA.VOICE_STATE.self_stream); }); @@ -102,7 +103,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.selfVideo).to.equal(TEST_DATA.VOICE_STATE.self_video); }); @@ -113,7 +114,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.suppress).to.equal(TEST_DATA.VOICE_STATE.suppress); }); @@ -124,7 +125,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); const guild = TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.guild).to.deep.equal(guild); }); @@ -135,7 +136,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.guildId).to.equal(TEST_DATA.GUILD_ID); }); @@ -147,7 +148,7 @@ describe("VoiceState", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.channel).to.be.an.instanceOf(VoiceChannel); }); @@ -158,7 +159,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.channelId).to.equal(TEST_DATA.VOICE_STATE.channel_id); }); @@ -168,12 +169,9 @@ describe("VoiceState", function () { it("should have the correct member value", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.member).to.be.an.instanceOf(Member); }); @@ -184,7 +182,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.memberId).to.equal(TEST_DATA.VOICE_STATE.user_id); }); @@ -195,7 +193,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.joined).to.be.a("number"); expect(voiceState.joined).to.equal(TEST_DATA.VOICE_STATE.joined); @@ -207,7 +205,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.requestToSpeakTimestamp).to.be.a("number"); expect(voiceState.requestToSpeakTimestamp).to.equal( @@ -223,7 +221,7 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.toString()).to.be.a("string"); }); @@ -234,19 +232,16 @@ describe("VoiceState", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.toJSON()).to.be.a("object"); }); it("should return the correct json", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.toJSON()).to.deep.equal({ deaf: TEST_DATA.VOICE_STATE.deaf, @@ -273,12 +268,9 @@ describe("VoiceState", function () { it("should return a valid JSON with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(voiceState.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT)).to.deep.equal({ _attributes: 56, @@ -379,16 +371,13 @@ describe("VoiceState", function () { it("should bundle correctly", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new VoiceState(client, voiceState.toJSON(), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); expect(rebundled.guildId).to.equal(voiceState.guildId); expect(rebundled.channelId).to.equal(voiceState.channelId); @@ -414,19 +403,16 @@ describe("VoiceState", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new VoiceState( client, voiceState.toJSON(TO_JSON_TYPES_ENUM.CACHE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.guildId).to.equal(voiceState.guildId); @@ -453,19 +439,16 @@ describe("VoiceState", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new VoiceState( client, voiceState.toJSON(TO_JSON_TYPES_ENUM.STORAGE_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.guildId).to.equal(voiceState.guildId); @@ -492,19 +475,16 @@ describe("VoiceState", function () { it("should bundle correctly with a custom toJSON", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); TEST_GUILDS.ALL_CACHES_ENABLED(client); - new Member(client, TEST_DATA.MEMBER, { - guild_id: TEST_DATA.GUILD_ID, - user_id: TEST_DATA.VOICE_STATE.user_id, - }); + TEST_MEMBERS.VOICE_STATE_MEMBER(client); TEST_CHANNELS.VOICE_CHANNEL_ALL_CACHES_ENABLED(client); const voiceState = new VoiceState(client, TEST_DATA.VOICE_STATE, { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }); const rebundled = new VoiceState( client, voiceState.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), { - guild_id: TEST_DATA.GUILD_ID, + guildId: TEST_DATA.GUILD_ID, }, ); expect(rebundled.guildId).to.equal(voiceState.guildId); diff --git a/test/util/discord/checkMemberPermissions.js b/test/util/discord/checkMemberPermissions.js index b18bb962..4ad53fb2 100644 --- a/test/util/discord/checkMemberPermissions.js +++ b/test/util/discord/checkMemberPermissions.js @@ -47,7 +47,7 @@ describe("CheckMemberPermissions", function () { PERMISSIONS.BAN_MEMBERS, ), }, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ), new Role( client, @@ -59,7 +59,7 @@ describe("CheckMemberPermissions", function () { PERMISSIONS.ADD_REACTIONS, ), }, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ), new Role( client, @@ -67,7 +67,7 @@ describe("CheckMemberPermissions", function () { id: TEST_DATA.ROLE_ID, permissions: combinePermissions(PERMISSIONS.BAN_MEMBERS), }, - { guild_id: TEST_DATA.GUILD_ID }, + { guildId: TEST_DATA.GUILD_ID }, ), ]; const calculatedPermissions = checkMemberPermissions(roles); diff --git a/test/util/general/structureHashName.js b/test/util/general/structureHashName.js index 54ca0d1f..54ed5796 100644 --- a/test/util/general/structureHashName.js +++ b/test/util/general/structureHashName.js @@ -36,8 +36,8 @@ describe("StructureHashName", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const message = new Message(client, TEST_DATA.MESSAGE, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, nocache: true, ignoreExisting: true, }); @@ -50,8 +50,8 @@ describe("StructureHashName", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const message = new Message(client, TEST_DATA.MESSAGE, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, nocache: true, ignoreExisting: true, }); diff --git a/test/util/gluon/encryptStructure.js b/test/util/gluon/encryptStructure.js index 7dc42146..4e48f582 100644 --- a/test/util/gluon/encryptStructure.js +++ b/test/util/gluon/encryptStructure.js @@ -42,8 +42,8 @@ describe("EncryptStructure", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const message = new Message(client, TEST_DATA.MESSAGE, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, nocache: true, ignoreExisting: true, }); @@ -61,8 +61,8 @@ describe("EncryptStructure", function () { TEST_GUILDS.ALL_CACHES_ENABLED(client); TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); const message = new Message(client, TEST_DATA.MESSAGE, { - channel_id: TEST_DATA.CHANNEL_ID, - guild_id: TEST_DATA.GUILD_ID, + channelId: TEST_DATA.CHANNEL_ID, + guildId: TEST_DATA.GUILD_ID, nocache: true, ignoreExisting: true, });