diff --git a/.idea/il-est-midi.iml b/.idea/il-est-midi.iml index d723fde1d..fe218caf4 100644 --- a/.idea/il-est-midi.iml +++ b/.idea/il-est-midi.iml @@ -28,7 +28,6 @@ - @@ -42,5 +41,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/classes/stores/abstract-entity-store.service.spec.ts b/src/classes/stores/abstract-entity-store.service.spec.ts index 86b2561a7..64c7018ea 100644 --- a/src/classes/stores/abstract-entity-store.service.spec.ts +++ b/src/classes/stores/abstract-entity-store.service.spec.ts @@ -1,7 +1,7 @@ import { AbstractEntityStoreService } from './abstract-entity-store.service'; import { ServiceNameEnum } from '../../enums/service-name.enum'; import { CoreEventService } from '../../features/core/services/core-event.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; interface IDummy { name: string; @@ -9,7 +9,7 @@ interface IDummy { class DummyService extends AbstractEntityStoreService { public constructor(serviceName: ServiceNameEnum) { - super(serviceName, createMock()); + super(serviceName, createHydratedMock()); } } diff --git a/src/classes/stores/abstract-store.service.spec.ts b/src/classes/stores/abstract-store.service.spec.ts index e9dae0f64..face90203 100644 --- a/src/classes/stores/abstract-store.service.spec.ts +++ b/src/classes/stores/abstract-store.service.spec.ts @@ -1,7 +1,7 @@ import { AbstractStoreService } from './abstract-store.service'; import { ServiceNameEnum } from '../../enums/service-name.enum'; import { CoreEventService } from '../../features/core/services/core-event.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; interface IDummy { name: string; @@ -9,7 +9,7 @@ interface IDummy { class DummyService extends AbstractStoreService { public constructor(serviceName: ServiceNameEnum) { - super(serviceName, createMock()); + super(serviceName, createHydratedMock()); } } diff --git a/src/features/discord/activities/services/discord-activity-sonia.service.spec.ts b/src/features/discord/activities/services/discord-activity-sonia.service.spec.ts index 2515ff117..2587f577a 100644 --- a/src/features/discord/activities/services/discord-activity-sonia.service.spec.ts +++ b/src/features/discord/activities/services/discord-activity-sonia.service.spec.ts @@ -15,7 +15,7 @@ import { Activity, Client, Presence, PresenceData } from 'discord.js'; import _ from 'lodash'; import * as NodeScheduleModule from 'node-schedule'; import { BehaviorSubject, noop } from 'rxjs'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); jest.mock(`node-schedule`); @@ -82,7 +82,7 @@ describe(`DiscordActivitySoniaService`, (): void => { beforeEach((): void => { service = new DiscordActivitySoniaService(); - presence = createMock(); + presence = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `isReady$`).mockReturnValue(isReady$); @@ -206,7 +206,7 @@ describe(`DiscordActivitySoniaService`, (): void => { .mockReturnValueOnce(`dummy-schedule`) .mockReturnValueOnce(`dummy-new-schedule`); service = new DiscordActivitySoniaService(); - job = createMock({ + job = createHydratedMock({ reschedule: jobRescheduleMock, }); @@ -567,7 +567,7 @@ describe(`DiscordActivitySoniaService`, (): void => { beforeEach((): void => { service = new DiscordActivitySoniaService(); - presence = createMock({ + presence = createHydratedMock({ activities: [ { name: DiscordActivityNameEnum.APOLLO, @@ -577,12 +577,12 @@ describe(`DiscordActivitySoniaService`, (): void => { ], }); setPresenceMock = jest.fn, unknown[]>().mockRejectedValue(new Error(`setPresence: error`)); - presenceActivity = createMock({ + presenceActivity = createHydratedMock({ name: DiscordActivityNameEnum.APOLLO, type: `PLAYING`, url: `dummy-url`, }); - client = createMock({ + client = createHydratedMock({ user: { setPresence: setPresenceMock, }, diff --git a/src/features/discord/authentications/services/discord-authentication.service.spec.ts b/src/features/discord/authentications/services/discord-authentication.service.spec.ts index 7f6c266ff..a9f2379c0 100644 --- a/src/features/discord/authentications/services/discord-authentication.service.spec.ts +++ b/src/features/discord/authentications/services/discord-authentication.service.spec.ts @@ -7,7 +7,7 @@ import { DiscordClientService } from '../../services/discord-client.service'; import { DiscordSoniaConfigService } from '../../users/services/config/discord-sonia-config.service'; import { Client } from 'discord.js'; import { take } from 'rxjs/operators'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -77,7 +77,7 @@ describe(`DiscordAuthenticationService`, (): void => { beforeEach((): void => { service = new DiscordAuthenticationService(); discordClientServiceGetClientOnMock = jest.fn(); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -111,7 +111,7 @@ describe(`DiscordAuthenticationService`, (): void => { discordClientServiceGetClientOnMock = jest.fn((_event: string, listener: () => void): void => { listener(); }); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -129,7 +129,7 @@ describe(`DiscordAuthenticationService`, (): void => { describe(`when the Discord client user is null`, (): void => { beforeEach((): void => { - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, user: null, }); @@ -155,7 +155,7 @@ describe(`DiscordAuthenticationService`, (): void => { beforeEach((): void => { tag = `dummy-tag`; - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, user: { tag, @@ -223,7 +223,7 @@ describe(`DiscordAuthenticationService`, (): void => { beforeEach((): void => { loginMock = jest.fn().mockResolvedValue(`login`); - client = createMock({ + client = createHydratedMock({ login: loginMock, }); @@ -278,7 +278,7 @@ describe(`DiscordAuthenticationService`, (): void => { describe(`when the login failed`, (): void => { beforeEach((): void => { loginMock = jest.fn().mockRejectedValue(new Error(`error`)); - client = createMock({ + client = createHydratedMock({ login: loginMock, }); @@ -329,7 +329,7 @@ describe(`DiscordAuthenticationService`, (): void => { describe(`when the login was successful`, (): void => { beforeEach((): void => { loginMock.mockResolvedValue(``); - client = createMock({ + client = createHydratedMock({ login: loginMock, }); diff --git a/src/features/discord/channels/functions/types/is-discord-guild-channel-writable.spec.ts b/src/features/discord/channels/functions/types/is-discord-guild-channel-writable.spec.ts index a1aa303ec..0a68ac9e0 100644 --- a/src/features/discord/channels/functions/types/is-discord-guild-channel-writable.spec.ts +++ b/src/features/discord/channels/functions/types/is-discord-guild-channel-writable.spec.ts @@ -1,14 +1,14 @@ import { isDiscordGuildChannelWritable } from './is-discord-guild-channel-writable'; import { CategoryChannel, GuildChannel, NewsChannel, StoreChannel, TextChannel, VoiceChannel } from 'discord.js'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`isDiscordGuildChannelWritable()`, (): void => { let guildChannel: GuildChannel; describe(`when the given guild channel is a text channel`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ isText(): boolean { return _.includes([`text`, `news`], guildChannel.type); }, @@ -26,7 +26,7 @@ describe(`isDiscordGuildChannelWritable()`, (): void => { describe(`when the given guild channel is a voice channel`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ isText(): boolean { return _.includes([`text`, `news`], guildChannel.type); }, @@ -44,7 +44,7 @@ describe(`isDiscordGuildChannelWritable()`, (): void => { describe(`when the given guild channel is a category channel`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ isText(): boolean { return _.includes([`text`, `news`], guildChannel.type); }, @@ -62,7 +62,7 @@ describe(`isDiscordGuildChannelWritable()`, (): void => { describe(`when the given guild channel is a news channel`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ isText(): boolean { return _.includes([`text`, `news`], guildChannel.type); }, @@ -80,7 +80,7 @@ describe(`isDiscordGuildChannelWritable()`, (): void => { describe(`when the given guild channel is a store channel`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ isText(): boolean { return _.includes([`text`, `news`], guildChannel.type); }, diff --git a/src/features/discord/channels/services/discord-channel-typing.service.spec.ts b/src/features/discord/channels/services/discord-channel-typing.service.spec.ts index 5d80e9a83..d0e87e694 100644 --- a/src/features/discord/channels/services/discord-channel-typing.service.spec.ts +++ b/src/features/discord/channels/services/discord-channel-typing.service.spec.ts @@ -4,7 +4,7 @@ import { CoreEventService } from '../../../core/services/core-event.service'; import { ILoggerLog } from '../../../logger/interfaces/logger-log'; import { LoggerService } from '../../../logger/services/logger.service'; import { DMChannel, NewsChannel, TextChannel } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -67,7 +67,7 @@ describe(`DiscordChannelTypingService`, (): void => { service = new DiscordChannelTypingService(); startTypingMock = jest.fn().mockRejectedValue(new Error(`startTyping error`)); - channel = createMock({ + channel = createHydratedMock({ startTyping: startTypingMock, }); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); @@ -85,7 +85,7 @@ describe(`DiscordChannelTypingService`, (): void => { describe(`when an error occur with Discord`, (): void => { beforeEach((): void => { startTypingMock.mockRejectedValue(new Error(`startTyping error`)); - channel = createMock({ + channel = createHydratedMock({ id: `dummy-channel-id`, startTyping: startTypingMock, }); @@ -111,7 +111,7 @@ describe(`DiscordChannelTypingService`, (): void => { describe(`when the typing indicator was successfully shown into Discord`, (): void => { beforeEach((): void => { startTypingMock.mockResolvedValue(undefined); - channel = createMock({ + channel = createHydratedMock({ id: `dummy-channel-id`, startTyping: startTypingMock, }); @@ -136,7 +136,7 @@ describe(`DiscordChannelTypingService`, (): void => { service = new DiscordChannelTypingService(); stopTypingMock = jest.fn().mockImplementation(); - channel = createMock({ + channel = createHydratedMock({ stopTyping: stopTypingMock, }); }); diff --git a/src/features/discord/emotional-states/services/discord-sonia-emotional-state.service.spec.ts b/src/features/discord/emotional-states/services/discord-sonia-emotional-state.service.spec.ts index 2d7f3632e..d70cfe5e5 100644 --- a/src/features/discord/emotional-states/services/discord-sonia-emotional-state.service.spec.ts +++ b/src/features/discord/emotional-states/services/discord-sonia-emotional-state.service.spec.ts @@ -12,7 +12,7 @@ import { DISCORD_EMOTIONAL_STATE_MESSAGES } from '../constants/discord-emotional import { DiscordSoniaEmotionalStateEnum } from '../enums/discord-sonia-emotional-state.enum'; import * as NodeScheduleModule from 'node-schedule'; import { BehaviorSubject, noop } from 'rxjs'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); jest.mock(`node-schedule`); @@ -203,7 +203,7 @@ describe(`DiscordSoniaEmotionalStateService`, (): void => { .mockReturnValueOnce(`dummy-schedule`) .mockReturnValueOnce(`dummy-new-schedule`); service = new DiscordSoniaEmotionalStateService(); - job = createMock({ + job = createHydratedMock({ reschedule: jobRescheduleMock, }); diff --git a/src/features/discord/guilds/services/__mocks__/discord-guild-sonia.service.ts b/src/features/discord/guilds/services/__mocks__/discord-guild-sonia.service.ts index 0afbcdf22..6f5d2154d 100644 --- a/src/features/discord/guilds/services/__mocks__/discord-guild-sonia.service.ts +++ b/src/features/discord/guilds/services/__mocks__/discord-guild-sonia.service.ts @@ -2,7 +2,7 @@ import { AbstractService } from '../../../../../classes/services/abstract.servic import { ServiceNameEnum } from '../../../../../enums/service-name.enum'; import { GuildChannel } from 'discord.js'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; export class DiscordGuildSoniaService extends AbstractService { private static _instance: DiscordGuildSoniaService; @@ -26,7 +26,7 @@ export class DiscordGuildSoniaService extends AbstractService { public sendMessageToChannel(): void {} public getSoniaGuildChannelByName(): GuildChannel | null | undefined { - return createMock(); + return createHydratedMock(); } // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/src/features/discord/guilds/services/discord-guild-create.service.spec.ts b/src/features/discord/guilds/services/discord-guild-create.service.spec.ts index 99b803649..52d3c6923 100644 --- a/src/features/discord/guilds/services/discord-guild-create.service.spec.ts +++ b/src/features/discord/guilds/services/discord-guild-create.service.spec.ts @@ -17,7 +17,7 @@ import { IDiscordGuildSoniaSendMessageToChannel } from '../interfaces/discord-gu import { Client, Guild, GuildChannel, Message, TextChannel } from 'discord.js'; import * as admin from 'firebase-admin'; import { of, throwError } from 'rxjs'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`./discord-guild-sonia.service`); jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -104,10 +104,10 @@ describe(`DiscordGuildCreateService`, (): void => { beforeEach((): void => { service = new DiscordGuildCreateService(); discordClientServiceGetClientOnMock = jest.fn(); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-guild-id`, }); @@ -144,7 +144,7 @@ describe(`DiscordGuildCreateService`, (): void => { discordClientServiceGetClientOnMock = jest.fn((_event: string, listener: (guild: Guild) => void): void => { listener(guild); }); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -291,11 +291,11 @@ describe(`DiscordGuildCreateService`, (): void => { beforeEach((): void => { service = new DiscordGuildCreateService(); - guild = createMock(); - primaryGuildChannel = createMock(); - discordMessageResponse = createMock(); - discordMessageErrorResponse = createMock(); - message = createMock(); + guild = createHydratedMock(); + primaryGuildChannel = createHydratedMock(); + discordMessageResponse = createHydratedMock(); + discordMessageErrorResponse = createHydratedMock(); + message = createHydratedMock(); discordGuildConfigServiceShouldSendCookiesOnCreateSpy = jest .spyOn(discordGuildConfigService, `shouldSendCookiesOnCreate`) @@ -390,14 +390,14 @@ describe(`DiscordGuildCreateService`, (): void => { describe(`when the primary guild channel was found`, (): void => { beforeEach((): void => { - primaryGuildChannel = createMock(); + primaryGuildChannel = createHydratedMock(); discordChannelGuildServiceGetPrimarySpy.mockReturnValue(primaryGuildChannel); }); describe(`when the primary guild channel is not writable`, (): void => { beforeEach((): void => { - primaryGuildChannel = createMock({ + primaryGuildChannel = createHydratedMock({ type: `voice`, }); @@ -427,7 +427,7 @@ describe(`DiscordGuildCreateService`, (): void => { describe(`when the primary guild channel is writable`, (): void => { beforeEach((): void => { - primaryGuildChannel = createMock({ + primaryGuildChannel = createHydratedMock({ isText(): true { return true; }, @@ -557,10 +557,10 @@ describe(`DiscordGuildCreateService`, (): void => { beforeEach((): void => { service = new DiscordGuildCreateService(); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsServiceIsReady$Spy = jest.spyOn(firebaseGuildsService, `isReady$`).mockReturnValue(of(true)); firebaseGuildsServiceHasGuildSpy = jest diff --git a/src/features/discord/guilds/services/discord-guild-member-add.service.spec.ts b/src/features/discord/guilds/services/discord-guild-member-add.service.spec.ts index 89ed313f8..020542e68 100644 --- a/src/features/discord/guilds/services/discord-guild-member-add.service.spec.ts +++ b/src/features/discord/guilds/services/discord-guild-member-add.service.spec.ts @@ -7,7 +7,7 @@ import { DiscordMessageRightsService } from '../../messages/services/rights/disc import { DiscordClientService } from '../../services/discord-client.service'; import { IAnyGuildMember } from '../types/any-guild-member'; import { Client } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -75,7 +75,7 @@ describe(`DiscordGuildMemberAddService`, (): void => { beforeEach((): void => { service = new DiscordGuildMemberAddService(); discordClientServiceGetClientOnMock = jest.fn(); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -107,7 +107,7 @@ describe(`DiscordGuildMemberAddService`, (): void => { discordClientServiceGetClientOnMock = jest.fn((_event: string, listener: () => void): void => { listener(); }); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -156,7 +156,7 @@ describe(`DiscordGuildMemberAddService`, (): void => { beforeEach((): void => { service = new DiscordGuildMemberAddService(); - member = createMock({ + member = createHydratedMock({ guild: { id: `dummy-guild-id`, }, diff --git a/src/features/discord/guilds/services/discord-guild.service.spec.ts b/src/features/discord/guilds/services/discord-guild.service.spec.ts index 9e97cf3e4..d3683a692 100644 --- a/src/features/discord/guilds/services/discord-guild.service.spec.ts +++ b/src/features/discord/guilds/services/discord-guild.service.spec.ts @@ -5,7 +5,7 @@ import { ILoggerLog } from '../../../logger/interfaces/logger-log'; import { LoggerService } from '../../../logger/services/logger.service'; import { DiscordClientService } from '../../services/discord-client.service'; import { Client, Guild, Snowflake } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -111,12 +111,12 @@ describe(`DiscordGuildService`, (): void => { beforeEach((): void => { service = new DiscordGuildService(); - guilds = [createMock(), createMock()]; + guilds = [createHydratedMock(), createHydratedMock()]; arrayMock = jest.fn().mockReturnValue(guilds); // @todo remove casting once https://github.com/Typescript-TDD/ts-auto-mock/issues/464 is fixed discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: ({ array: arrayMock, @@ -155,7 +155,7 @@ describe(`DiscordGuildService`, (): void => { beforeEach((): void => { service = new DiscordGuildService(); - guild = createMock(); + guild = createHydratedMock(); findMock = jest.fn().mockImplementation( (fn: (value: Guild) => boolean): Guild => { @@ -166,7 +166,7 @@ describe(`DiscordGuildService`, (): void => { ); // @todo remove casting once https://github.com/Typescript-TDD/ts-auto-mock/issues/464 is fixed discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: ({ find: findMock, diff --git a/src/features/discord/logger/services/__mocks__/discord-logger-error.service.ts b/src/features/discord/logger/services/__mocks__/discord-logger-error.service.ts index 815f38c1d..ef23fa3bd 100644 --- a/src/features/discord/logger/services/__mocks__/discord-logger-error.service.ts +++ b/src/features/discord/logger/services/__mocks__/discord-logger-error.service.ts @@ -3,7 +3,7 @@ import { ServiceNameEnum } from '../../../../../enums/service-name.enum'; import { IDiscordMessageResponse } from '../../../messages/interfaces/discord-message-response'; import { MessageEmbed } from 'discord.js'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; export class DiscordLoggerErrorService extends AbstractService { private static _instance: DiscordLoggerErrorService; @@ -26,7 +26,7 @@ export class DiscordLoggerErrorService extends AbstractService { public getErrorMessageResponse(): IDiscordMessageResponse { return { options: { - embed: createMock(), + embed: createHydratedMock(), split: false, }, response: ``, diff --git a/src/features/discord/logger/services/discord-logger-error.service.spec.ts b/src/features/discord/logger/services/discord-logger-error.service.spec.ts index 9d23328f7..ddc6f34f5 100644 --- a/src/features/discord/logger/services/discord-logger-error.service.spec.ts +++ b/src/features/discord/logger/services/discord-logger-error.service.spec.ts @@ -14,7 +14,7 @@ import cryptoRandomString from 'crypto-random-string'; import { MessageEmbedAuthor } from 'discord.js'; import _ from 'lodash'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -84,7 +84,7 @@ describe(`DiscordLoggerErrorService`, (): void => { beforeEach((): void => { service = new DiscordLoggerErrorService(); - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); @@ -224,7 +224,7 @@ describe(`DiscordLoggerErrorService`, (): void => { it(`should return an error message response with an embed author`, (): void => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = service.getErrorMessageResponse(error); diff --git a/src/features/discord/logger/services/discord-logger-warning.service.spec.ts b/src/features/discord/logger/services/discord-logger-warning.service.spec.ts index dfb5f9248..54005060e 100644 --- a/src/features/discord/logger/services/discord-logger-warning.service.spec.ts +++ b/src/features/discord/logger/services/discord-logger-warning.service.spec.ts @@ -12,7 +12,7 @@ import { DiscordMessageConfigService } from '../../messages/services/config/disc import { DiscordSoniaService } from '../../users/services/discord-sonia.service'; import { MessageEmbedAuthor } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -83,7 +83,7 @@ describe(`DiscordLoggerWarningService`, (): void => { beforeEach((): void => { service = new DiscordLoggerWarningService(); warning = `dummy-warning`; - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceWarningSpy = jest.spyOn(loggerService, `warning`).mockImplementation(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); @@ -166,7 +166,7 @@ describe(`DiscordLoggerWarningService`, (): void => { it(`should return a warning message response with an embed author`, (): void => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = service.getWarningMessageResponse(warning); diff --git a/src/features/discord/logger/services/discord-logger.service.spec.ts b/src/features/discord/logger/services/discord-logger.service.spec.ts index fad0e8422..b0c5dcd04 100644 --- a/src/features/discord/logger/services/discord-logger.service.spec.ts +++ b/src/features/discord/logger/services/discord-logger.service.spec.ts @@ -7,7 +7,7 @@ import { ILoggerLog } from '../../../logger/interfaces/logger-log'; import { LoggerService } from '../../../logger/services/logger.service'; import { DiscordClientService } from '../../services/discord-client.service'; import { Client } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -76,7 +76,7 @@ describe(`DiscordLoggerService`, (): void => { beforeEach((): void => { service = new DiscordLoggerService(); discordClientServiceGetClientOnMock = jest.fn(); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -114,7 +114,7 @@ describe(`DiscordLoggerService`, (): void => { discordClientServiceGetClientOnMock = jest.fn((_event: string, listener: () => void): void => { listener(); }); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -157,7 +157,7 @@ describe(`DiscordLoggerService`, (): void => { discordClientServiceGetClientOnMock = jest.fn((_event: string, listener: () => void): void => { listener(); }); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); diff --git a/src/features/discord/messages/classes/commands/arguments/discord-command-first-argument.spec.ts b/src/features/discord/messages/classes/commands/arguments/discord-command-first-argument.spec.ts index 1353eec8d..721441d8b 100644 --- a/src/features/discord/messages/classes/commands/arguments/discord-command-first-argument.spec.ts +++ b/src/features/discord/messages/classes/commands/arguments/discord-command-first-argument.spec.ts @@ -1,7 +1,7 @@ import { DiscordCommandFirstArgument } from './discord-command-first-argument'; import { IDiscordCommandFirstArgument } from '../../../interfaces/commands/discord-command-first-argument'; import { DiscordMessageCommandFeatureNameEnum } from '../../../services/command/feature/enums/discord-message-command-feature-name.enum'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordCommandFirstArgument`, (): void => { let discordCommandFirstArgument: DiscordCommandFirstArgument; @@ -12,7 +12,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { expect.assertions(1); discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ description: `dummy-description`, }) ); @@ -26,7 +26,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { expect.assertions(1); discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -41,7 +41,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { expect.assertions(1); discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ shortcuts: undefined, }) ); @@ -55,7 +55,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { expect.assertions(1); discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ shortcuts: [DiscordMessageCommandFeatureNameEnum.N], }) ); @@ -69,7 +69,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getDescription()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -86,7 +86,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`setDescription()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -102,7 +102,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getName()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -119,7 +119,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getLowerCaseName()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -136,7 +136,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`setName()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -152,7 +152,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getShortcuts()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -169,7 +169,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getLowerCaseShortcuts()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -189,7 +189,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`setShortcuts()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>() + createHydratedMock>() ); }); @@ -205,7 +205,7 @@ describe(`DiscordCommandFirstArgument`, (): void => { describe(`getLowerCaseNameAndShortcutsExample()`, (): void => { beforeEach((): void => { discordCommandFirstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); diff --git a/src/features/discord/messages/classes/commands/arguments/discord-command-first-arguments.spec.ts b/src/features/discord/messages/classes/commands/arguments/discord-command-first-arguments.spec.ts index 5d0cee3d8..cfefa8146 100644 --- a/src/features/discord/messages/classes/commands/arguments/discord-command-first-arguments.spec.ts +++ b/src/features/discord/messages/classes/commands/arguments/discord-command-first-arguments.spec.ts @@ -2,7 +2,7 @@ import { DiscordCommandFirstArgument } from './discord-command-first-argument'; import { DiscordCommandFirstArguments } from './discord-command-first-arguments'; import { IDiscordCommandFirstArgument } from '../../../interfaces/commands/discord-command-first-argument'; import { DiscordMessageCommandFeatureNameEnum } from '../../../services/command/feature/enums/discord-message-command-feature-name.enum'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordCommandFirstArguments`, (): void => { let discordCommandFirstArguments: DiscordCommandFirstArguments; @@ -11,7 +11,9 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`when the class is created with some arguments`, (): void => { it(`should update the arguments inside the class`, (): void => { expect.assertions(1); - const firstArguments = createMock[]>(); + const firstArguments = createHydratedMock< + DiscordCommandFirstArgument[] + >(); discordCommandFirstArguments = new DiscordCommandFirstArguments( firstArguments @@ -25,13 +27,13 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getArguments()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); it(`should return the arguments`, (): void => { expect.assertions(1); - const firstArguments = createMock[]>(); + const firstArguments = createHydratedMock[]>(); discordCommandFirstArguments.setArguments(firstArguments); const result = discordCommandFirstArguments.getArguments(); @@ -43,13 +45,13 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`setArguments()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); it(`should update the arguments with the given ones`, (): void => { expect.assertions(1); - const firstArguments = createMock[]>(); + const firstArguments = createHydratedMock[]>(); discordCommandFirstArguments.setArguments(firstArguments); @@ -60,7 +62,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getRandomArgument()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -82,7 +84,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { let firstArgument: DiscordCommandFirstArgument; beforeEach((): void => { - firstArgument = createMock>(); + firstArgument = createHydratedMock>(); discordCommandFirstArguments.setArguments([firstArgument]); }); @@ -100,8 +102,8 @@ describe(`DiscordCommandFirstArguments`, (): void => { let firstArgument2: DiscordCommandFirstArgument; beforeEach((): void => { - firstArgument1 = createMock>(); - firstArgument2 = createMock>(); + firstArgument1 = createHydratedMock>(); + firstArgument2 = createHydratedMock>(); discordCommandFirstArguments.setArguments([firstArgument1, firstArgument2]); }); @@ -118,7 +120,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getRandomArgumentUsageExample()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -141,7 +143,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -161,7 +163,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getAllArgumentsNameExample()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -184,7 +186,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -206,12 +208,12 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, }) ); @@ -231,7 +233,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getAllArgumentsNameWithShortcutsExample()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -254,7 +256,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -275,7 +277,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, shortcuts: [DiscordMessageCommandFeatureNameEnum.N, DiscordMessageCommandFeatureNameEnum.N], }) @@ -298,12 +300,12 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, }) ); @@ -325,13 +327,13 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, shortcuts: [DiscordMessageCommandFeatureNameEnum.N, DiscordMessageCommandFeatureNameEnum.N], }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, shortcuts: [DiscordMessageCommandFeatureNameEnum.N, DiscordMessageCommandFeatureNameEnum.N], }) @@ -352,7 +354,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getAllArgumentsLowerCaseName()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -375,7 +377,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -397,12 +399,12 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, }) ); @@ -422,7 +424,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { describe(`getAllArgumentsLowerCaseNameWithShortcuts()`, (): void => { beforeEach((): void => { discordCommandFirstArguments = new DiscordCommandFirstArguments( - createMock[]>() + createHydratedMock[]>() ); }); @@ -445,7 +447,7 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, }) ); @@ -467,13 +469,13 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, shortcuts: [DiscordMessageCommandFeatureNameEnum.N], }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, shortcuts: [DiscordMessageCommandFeatureNameEnum.NOON], }) @@ -496,13 +498,13 @@ describe(`DiscordCommandFirstArguments`, (): void => { beforeEach((): void => { firstArgument1 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.NOON, shortcuts: [DiscordMessageCommandFeatureNameEnum.N, DiscordMessageCommandFeatureNameEnum.N], }) ); firstArgument2 = new DiscordCommandFirstArgument( - createMock>({ + createHydratedMock>({ name: DiscordMessageCommandFeatureNameEnum.N, shortcuts: [DiscordMessageCommandFeatureNameEnum.NOON, DiscordMessageCommandFeatureNameEnum.NOON], }) diff --git a/src/features/discord/messages/classes/commands/flags/discord-command-boolean-flag.spec.ts b/src/features/discord/messages/classes/commands/flags/discord-command-boolean-flag.spec.ts index 5e6c8273e..750ed57de 100644 --- a/src/features/discord/messages/classes/commands/flags/discord-command-boolean-flag.spec.ts +++ b/src/features/discord/messages/classes/commands/flags/discord-command-boolean-flag.spec.ts @@ -7,7 +7,7 @@ import { IDiscordCommandFlagSuccess } from '../../../interfaces/commands/flags/d import { IDiscordCommandFlag } from '../../../interfaces/commands/flags/discord-command-flag'; import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { IDiscordMessageFlag } from '../../../types/commands/flags/discord-message-flag'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; enum DummyFlagEnum { ALPHA = `alpha-flag`, @@ -22,12 +22,13 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`when the class is created with an action`, (): void => { it(`should update the action inside the class`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ action, }) ); @@ -41,7 +42,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ description: `dummy-description`, }) ); @@ -55,7 +56,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -70,7 +71,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ shortcuts: undefined, }) ); @@ -84,7 +85,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ shortcuts: [DummyFlagEnum.BETA], }) ); @@ -98,14 +99,15 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getAction()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); it(`should return the action`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag.setAction(action); @@ -118,14 +120,15 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setAction()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); it(`should update the action with the given one`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag.setAction(action); @@ -137,7 +140,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getDescription()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -154,7 +157,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setDescription()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -170,7 +173,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -187,7 +190,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getLowerCaseName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -204,7 +207,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getHumanizedName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -221,7 +224,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -237,7 +240,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getOpposites()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -254,7 +257,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setOpposites()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -270,7 +273,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -287,7 +290,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getLowerCaseShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -304,7 +307,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -320,7 +323,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getType()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -337,7 +340,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`setType()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -353,7 +356,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { describe(`getLowerCaseNameAndShortcutsExample()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -421,7 +424,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -517,7 +520,7 @@ describe(`DiscordCommandBooleanFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -714,17 +717,17 @@ describe(`DiscordCommandBooleanFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); messageFlag = `--alpha-flag=true`; - discordCommandFlags = createMock>(); - discordCommandFlagSuccess = createMock(); + discordCommandFlags = createHydratedMock>(); + discordCommandFlagSuccess = createHydratedMock(); }); it(`should execute the action`, async (): Promise => { expect.assertions(1); - const action = createMock>({ + const action = createHydratedMock>({ execute: (): Promise => Promise.resolve(discordCommandFlagSuccess), }); discordCommandFlag.setAction(action); diff --git a/src/features/discord/messages/classes/commands/flags/discord-command-flags.spec.ts b/src/features/discord/messages/classes/commands/flags/discord-command-flags.spec.ts index f00864f0a..d1aae0044 100644 --- a/src/features/discord/messages/classes/commands/flags/discord-command-flags.spec.ts +++ b/src/features/discord/messages/classes/commands/flags/discord-command-flags.spec.ts @@ -13,7 +13,7 @@ import { IDiscordCommandFlagsErrors } from '../../../types/commands/flags/discor import { IDiscordCommandFlagsOpposite } from '../../../types/commands/flags/discord-command-flags-opposite'; import { IDiscordMessageFlag } from '../../../types/commands/flags/discord-message-flag'; import { DiscordCommandFirstArgument } from '../arguments/discord-command-first-argument'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -57,7 +57,7 @@ describe(`DiscordCommandFlags`, (): void => { discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); expect(discordCommandFlags.getCommand()).toStrictEqual(alphaArgument); @@ -69,7 +69,7 @@ describe(`DiscordCommandFlags`, (): void => { it(`should update the flags inside the class`, (): void => { expect.assertions(1); - const flags = createMock[]>(); + const flags = createHydratedMock[]>(); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, @@ -93,7 +93,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -119,7 +119,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -145,15 +145,17 @@ describe(`DiscordCommandFlags`, (): void => { shortcuts: [DummyFirstArgumentEnum.BETA], }); alphaFlag = new DiscordCommandBooleanFlag({ - action: createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + action: createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.ALPHA, }); betaFlag = new DiscordCommandBooleanFlag({ - action: createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + action: createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.BETA, @@ -185,15 +187,17 @@ describe(`DiscordCommandFlags`, (): void => { name: DummyFirstArgumentEnum.ALPHA, }); alphaFlag = new DiscordCommandBooleanFlag({ - action: createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + action: createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.ALPHA, }); betaFlag = new DiscordCommandBooleanFlag({ - action: createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + action: createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.BETA, @@ -225,13 +229,13 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); it(`should update the flags with the given ones`, (): void => { expect.assertions(1); - const flags = createMock[]>(); + const flags = createHydratedMock[]>(); discordCommandFlags.setFlags(flags); @@ -251,7 +255,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -273,7 +277,7 @@ describe(`DiscordCommandFlags`, (): void => { let flag: DiscordCommandBooleanFlag; beforeEach((): void => { - flag = createMock>(); + flag = createHydratedMock>(); discordCommandFlags.setFlags([flag]); }); @@ -291,8 +295,8 @@ describe(`DiscordCommandFlags`, (): void => { let flag2: DiscordCommandBooleanFlag; beforeEach((): void => { - flag1 = createMock>(); - flag2 = createMock>(); + flag1 = createHydratedMock>(); + flag2 = createHydratedMock>(); discordCommandFlags.setFlags([flag1, flag2]); }); @@ -318,7 +322,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -341,7 +345,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>() + createHydratedMock>>() ); discordCommandFlags.setFlags([flag]); }); @@ -376,7 +380,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -399,7 +403,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -427,17 +431,17 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.BETA, }) ); flag3 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.CHARLIE, }) ); @@ -479,7 +483,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -502,7 +506,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -524,12 +528,12 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.BETA, }) ); @@ -558,7 +562,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -581,7 +585,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -602,7 +606,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, shortcuts: [DummyFlagEnum.BETA, DummyFlagEnum.CHARLIE], }) @@ -625,12 +629,12 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.BETA, }) ); @@ -652,13 +656,13 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, shortcuts: [DummyFlagEnum.BETA, DummyFlagEnum.CHARLIE], }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.DELTA, shortcuts: [DummyFlagEnum.ECHO, DummyFlagEnum.FOXTROT], }) @@ -690,7 +694,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -713,7 +717,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -735,12 +739,12 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.BETA, }) ); @@ -769,7 +773,7 @@ describe(`DiscordCommandFlags`, (): void => { }); discordCommandFlags = new DiscordCommandFlags({ command: alphaArgument, - flags: createMock[]>(), + flags: createHydratedMock[]>(), }); }); @@ -792,7 +796,7 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -814,13 +818,13 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, shortcuts: [DummyFlagEnum.BETA], }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.CHARLIE, shortcuts: [DummyFlagEnum.DELTA], }) @@ -843,13 +847,13 @@ describe(`DiscordCommandFlags`, (): void => { beforeEach((): void => { flag1 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, shortcuts: [DummyFlagEnum.BETA, DummyFlagEnum.CHARLIE], }) ); flag2 = new DiscordCommandBooleanFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.DELTA, shortcuts: [DummyFlagEnum.ECHO, DummyFlagEnum.FOXTROT], }) @@ -889,9 +893,9 @@ describe(`DiscordCommandFlags`, (): void => { command: alphaArgument, flags: [ new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.ALPHA, @@ -2255,35 +2259,35 @@ describe(`DiscordCommandFlags`, (): void => { command: alphaArgument, flags: [ new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.ALPHA, shortcuts: [DummyFlagEnum.BETA], }), new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: `dummy`, }), new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: `other`, shortcuts: [`t`], }), new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: `three`, @@ -2449,9 +2453,9 @@ describe(`DiscordCommandFlags`, (): void => { command: alphaArgument, flags: [ new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.ALPHA, @@ -2459,9 +2463,9 @@ describe(`DiscordCommandFlags`, (): void => { shortcuts: [DummyFlagEnum.BETA], }), new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: (): Promise => - Promise.resolve(createMock()), + Promise.resolve(createHydratedMock()), }), description: ``, name: DummyFlagEnum.CHARLIE, @@ -2637,7 +2641,7 @@ describe(`DiscordCommandFlags`, (): void => { name: DummyFirstArgumentEnum.ALPHA, shortcuts: [DummyFirstArgumentEnum.BETA], }); - discordCommandFlagSuccess = createMock(); + discordCommandFlagSuccess = createHydratedMock(); actionMock = jest .fn, unknown[]>() .mockResolvedValue(discordCommandFlagSuccess); @@ -2645,7 +2649,7 @@ describe(`DiscordCommandFlags`, (): void => { command: alphaArgument, flags: [ new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: actionMock, }), description: ``, @@ -2654,7 +2658,7 @@ describe(`DiscordCommandFlags`, (): void => { }), ], }); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); messageFlags = `--alpha-flag=true`; @@ -3119,7 +3123,7 @@ describe(`DiscordCommandFlags`, (): void => { name: DummyFirstArgumentEnum.ALPHA, shortcuts: [DummyFirstArgumentEnum.BETA], }); - discordCommandFlagSuccess = createMock(); + discordCommandFlagSuccess = createHydratedMock(); actionMock = jest .fn, unknown[]>() .mockResolvedValue(discordCommandFlagSuccess); @@ -3127,7 +3131,7 @@ describe(`DiscordCommandFlags`, (): void => { command: alphaArgument, flags: [ new DiscordCommandBooleanFlag({ - action: createMock>({ + action: createHydratedMock>({ execute: actionMock, }), description: ``, @@ -3136,7 +3140,7 @@ describe(`DiscordCommandFlags`, (): void => { }), ], }); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); messageFlag = `--alpha-flag=true`; diff --git a/src/features/discord/messages/classes/commands/flags/discord-command-valueless-flag.spec.ts b/src/features/discord/messages/classes/commands/flags/discord-command-valueless-flag.spec.ts index 05ab20a44..ddef29987 100644 --- a/src/features/discord/messages/classes/commands/flags/discord-command-valueless-flag.spec.ts +++ b/src/features/discord/messages/classes/commands/flags/discord-command-valueless-flag.spec.ts @@ -7,7 +7,7 @@ import { IDiscordCommandFlagSuccess } from '../../../interfaces/commands/flags/d import { IDiscordCommandFlag } from '../../../interfaces/commands/flags/discord-command-flag'; import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { IDiscordMessageFlag } from '../../../types/commands/flags/discord-message-flag'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; enum DummyFlagEnum { ALPHA = `alpha-flag`, @@ -22,12 +22,13 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`when the class is created with an action`, (): void => { it(`should update the action inside the class`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ action, }) ); @@ -41,7 +42,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ description: `dummy-description`, }) ); @@ -55,7 +56,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -70,7 +71,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ shortcuts: undefined, }) ); @@ -84,7 +85,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { expect.assertions(1); discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ shortcuts: [DummyFlagEnum.BETA], }) ); @@ -98,14 +99,15 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getAction()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); it(`should return the action`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag.setAction(action); @@ -118,14 +120,15 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setAction()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); it(`should update the action with the given one`, (): void => { expect.assertions(1); - const action = createMock>({ - execute: (): Promise => Promise.resolve(createMock()), + const action = createHydratedMock>({ + execute: (): Promise => + Promise.resolve(createHydratedMock()), }); discordCommandFlag.setAction(action); @@ -137,7 +140,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getDescription()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -154,7 +157,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setDescription()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -170,7 +173,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -187,7 +190,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getLowerCaseName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -204,7 +207,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getHumanizedName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -221,7 +224,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setName()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -237,7 +240,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getOpposites()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -254,7 +257,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setOpposites()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -270,7 +273,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -287,7 +290,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getLowerCaseShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -304,7 +307,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setShortcuts()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -320,7 +323,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getType()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -337,7 +340,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`setType()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); }); @@ -353,7 +356,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { describe(`getLowerCaseNameAndShortcutsExample()`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -421,7 +424,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -517,7 +520,7 @@ describe(`DiscordCommandValuelessFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>({ + createHydratedMock>>({ name: DummyFlagEnum.ALPHA, }) ); @@ -722,17 +725,17 @@ describe(`DiscordCommandValuelessFlag`, (): void => { beforeEach((): void => { discordCommandFlag = new DiscordCommandValuelessFlag( - createMock>>() + createHydratedMock>>() ); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); messageFlag = `--alpha-flag`; - discordCommandFlags = createMock>(); - discordCommandFlagSuccess = createMock(); + discordCommandFlags = createHydratedMock>(); + discordCommandFlagSuccess = createHydratedMock(); }); it(`should execute the action`, async (): Promise => { expect.assertions(1); - const action = createMock>({ + const action = createHydratedMock>({ execute: (): Promise => Promise.resolve(discordCommandFlagSuccess), }); discordCommandFlag.setAction(action); diff --git a/src/features/discord/messages/classes/messages.spec.ts b/src/features/discord/messages/classes/messages.spec.ts index 3e20ff8b8..9cfafc366 100644 --- a/src/features/discord/messages/classes/messages.spec.ts +++ b/src/features/discord/messages/classes/messages.spec.ts @@ -3,7 +3,7 @@ import { IObject } from '../../../../types/object'; import { DiscordSoniaEmotionalStateEnum } from '../../emotional-states/enums/discord-sonia-emotional-state.enum'; import { IMessageConfig } from '../interfaces/message-config'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; enum DummyEnum { WITH_VAR = `dummy message with {{ variable }}`, @@ -18,7 +18,7 @@ describe(`Messages`, (): void => { expect.assertions(1); messages = new Messages( - createMock>({ + createHydratedMock>({ defaultMessage: DiscordSoniaEmotionalStateEnum.CRAZY, }) ); @@ -32,7 +32,7 @@ describe(`Messages`, (): void => { expect.assertions(1); messages = new Messages( - createMock>({ + createHydratedMock>({ messages: DiscordSoniaEmotionalStateEnum, }) ); @@ -46,7 +46,7 @@ describe(`Messages`, (): void => { expect.assertions(1); messages = new Messages( - createMock>({ + createHydratedMock>({ params: { key1: `value1`, }, @@ -63,7 +63,7 @@ describe(`Messages`, (): void => { describe(`getDefaultMessage()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -80,7 +80,7 @@ describe(`Messages`, (): void => { describe(`setDefaultMessage()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -96,7 +96,7 @@ describe(`Messages`, (): void => { describe(`getMessages()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -113,7 +113,7 @@ describe(`Messages`, (): void => { describe(`setMessages()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -129,7 +129,7 @@ describe(`Messages`, (): void => { describe(`getParams()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -150,7 +150,7 @@ describe(`Messages`, (): void => { describe(`setParams()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>() + createHydratedMock>() ); }); @@ -170,7 +170,7 @@ describe(`Messages`, (): void => { describe(`getRandomMessage()`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>({ + createHydratedMock>({ defaultMessage: DiscordSoniaEmotionalStateEnum.AGITATED, }) ); @@ -210,7 +210,7 @@ describe(`Messages`, (): void => { beforeEach((): void => { messages = new Messages( - createMock>({ + createHydratedMock>({ defaultMessage: DummyEnum.WITH_VAR, }) ); diff --git a/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-one-of-these-prefixes.spec.ts b/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-one-of-these-prefixes.spec.ts index f12aed150..d7c2ad10c 100644 --- a/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-one-of-these-prefixes.spec.ts +++ b/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-one-of-these-prefixes.spec.ts @@ -1,13 +1,13 @@ import { discordContainsThisCommandWithOneOfThesePrefixes } from './discord-contains-this-command-with-one-of-these-prefixes'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordContainsThisCommandWithOneOfThesePrefixesData } from '../../../interfaces/commands/checks/discord-contains-this-command-with-one-of-these-prefixes-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`containsThisCommandWithOneOfThesePrefixes()`, (): void => { let data: IDiscordContainsThisCommandWithOneOfThesePrefixesData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the message is empty`, (): void => { diff --git a/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-prefix.spec.ts b/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-prefix.spec.ts index 585f6dabe..6d9ae14e0 100644 --- a/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-prefix.spec.ts +++ b/src/features/discord/messages/functions/commands/checks/discord-contains-this-command-with-prefix.spec.ts @@ -1,13 +1,13 @@ import { discordContainsThisCommandWithPrefix } from './discord-contains-this-command-with-prefix'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordContainsThisCommandWithPrefixData } from '../../../interfaces/commands/checks/discord-contains-this-command-with-prefix-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`containsThisCommandWithPrefix()`, (): void => { let data: IDiscordContainsThisCommandWithPrefixData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the message is empty`, (): void => { diff --git a/src/features/discord/messages/functions/commands/checks/discord-has-this-command.spec.ts b/src/features/discord/messages/functions/commands/checks/discord-has-this-command.spec.ts index 00adc1b7a..2992f6429 100644 --- a/src/features/discord/messages/functions/commands/checks/discord-has-this-command.spec.ts +++ b/src/features/discord/messages/functions/commands/checks/discord-has-this-command.spec.ts @@ -1,13 +1,13 @@ import { discordHasThisCommand } from './discord-has-this-command'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordHasThisCommandData } from '../../../interfaces/commands/checks/discord-has-this-command-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`hasThisCommand()`, (): void => { let data: IDiscordHasThisCommandData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the message is empty`, (): void => { diff --git a/src/features/discord/messages/functions/commands/checks/discord-strictly-contains-this-command-with-prefix.spec.ts b/src/features/discord/messages/functions/commands/checks/discord-strictly-contains-this-command-with-prefix.spec.ts index d4466239e..51267f17e 100644 --- a/src/features/discord/messages/functions/commands/checks/discord-strictly-contains-this-command-with-prefix.spec.ts +++ b/src/features/discord/messages/functions/commands/checks/discord-strictly-contains-this-command-with-prefix.spec.ts @@ -1,13 +1,13 @@ import { discordStrictlyContainsThisCommandWithPrefix } from './discord-strictly-contains-this-command-with-prefix'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordStrictlyContainsThisCommandWithPrefixData } from '../../../interfaces/commands/checks/discord-strictly-contains-this-command-with-prefix-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`strictlyContainsThisCommandWithPrefix()`, (): void => { let data: IDiscordStrictlyContainsThisCommandWithPrefixData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the message is empty`, (): void => { diff --git a/src/features/discord/messages/functions/commands/flags/discord-command-is-flag-success.spec.ts b/src/features/discord/messages/functions/commands/flags/discord-command-is-flag-success.spec.ts index 63d222ef8..74c6fa508 100644 --- a/src/features/discord/messages/functions/commands/flags/discord-command-is-flag-success.spec.ts +++ b/src/features/discord/messages/functions/commands/flags/discord-command-is-flag-success.spec.ts @@ -3,14 +3,14 @@ import { IDiscordCommandFlagSuccess } from '../../../interfaces/commands/flags/d import { IDiscordMessageResponse } from '../../../interfaces/discord-message-response'; import { DiscordMessageCommandNoonFlagSuccessTitleEnum } from '../../../services/command/feature/features/noon/enums/discord-message-command-noon-flag-success-title.enum'; import { IDiscordCommandFlagResponse } from '../../../types/commands/flags/discord-command-flag-response'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordCommandIsFlagSuccess()`, (): void => { let value: IDiscordCommandFlagResponse; describe(`when the given value is a Discord message response`, (): void => { beforeEach((): void => { - value = createMock(); + value = createHydratedMock(); }); it(`should return false`, (): void => { @@ -24,7 +24,7 @@ describe(`discordCommandIsFlagSuccess()`, (): void => { describe(`when the given value is a Discord command flag success`, (): void => { beforeEach((): void => { - value = createMock({ + value = createHydratedMock({ description: ``, name: DiscordMessageCommandNoonFlagSuccessTitleEnum.NOON_FEATURE_ENABLED, }); diff --git a/src/features/discord/messages/functions/commands/flags/discord-command-split-flags-response.spec.ts b/src/features/discord/messages/functions/commands/flags/discord-command-split-flags-response.spec.ts index 43a4b5536..2a1b70406 100644 --- a/src/features/discord/messages/functions/commands/flags/discord-command-split-flags-response.spec.ts +++ b/src/features/discord/messages/functions/commands/flags/discord-command-split-flags-response.spec.ts @@ -2,7 +2,7 @@ import { discordCommandSplitFlagsResponse } from './discord-command-split-flags- import { IDiscordCommandFlagSuccess } from '../../../interfaces/commands/flags/discord-command-flag-success'; import { IDiscordMessageResponse } from '../../../interfaces/discord-message-response'; import { IDiscordCommandFlagsResponse } from '../../../types/commands/flags/discord-command-flags-response'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordCommandSplitFlagsResponse()`, (): void => { let discordCommandFlagsResponse: IDiscordCommandFlagsResponse; @@ -11,7 +11,7 @@ describe(`discordCommandSplitFlagsResponse()`, (): void => { let discordCommandFlagSuccess: IDiscordCommandFlagSuccess; beforeEach((): void => { - discordCommandFlagSuccess = createMock(); + discordCommandFlagSuccess = createHydratedMock(); discordCommandFlagsResponse = [discordCommandFlagSuccess]; }); @@ -30,8 +30,8 @@ describe(`discordCommandSplitFlagsResponse()`, (): void => { let discordCommandFlagSuccessB: IDiscordCommandFlagSuccess; beforeEach((): void => { - discordCommandFlagSuccessA = createMock(); - discordCommandFlagSuccessB = createMock(); + discordCommandFlagSuccessA = createHydratedMock(); + discordCommandFlagSuccessB = createHydratedMock(); discordCommandFlagsResponse = [discordCommandFlagSuccessA, discordCommandFlagSuccessB]; }); @@ -52,10 +52,10 @@ describe(`discordCommandSplitFlagsResponse()`, (): void => { let discordMessageResponseB: IDiscordMessageResponse; beforeEach((): void => { - discordCommandFlagSuccessA = createMock(); - discordCommandFlagSuccessB = createMock(); - discordMessageResponseA = createMock(); - discordMessageResponseB = createMock(); + discordCommandFlagSuccessA = createHydratedMock(); + discordCommandFlagSuccessB = createHydratedMock(); + discordMessageResponseA = createHydratedMock(); + discordMessageResponseB = createHydratedMock(); discordCommandFlagsResponse = [ discordCommandFlagSuccessA, discordCommandFlagSuccessB, diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-command-and-first-argument.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-command-and-first-argument.spec.ts index f7031639b..534c14d82 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-command-and-first-argument.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-command-and-first-argument.spec.ts @@ -1,13 +1,13 @@ import { discordGetCommandAndFirstArgument } from './discord-get-command-and-first-argument'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandAndFirstArgumentData } from '../../../interfaces/commands/getters/discord-get-command-and-first-argument-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetCommandAndFirstArgument()`, (): void => { let data: IDiscordGetCommandAndFirstArgumentData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-command-and-prefix.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-command-and-prefix.spec.ts index 2ac7bedd9..cf13149b1 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-command-and-prefix.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-command-and-prefix.spec.ts @@ -1,13 +1,13 @@ import { discordGetCommandAndPrefix } from './discord-get-command-and-prefix'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandAndPrefixData } from '../../../interfaces/commands/getters/discord-get-command-and-prefix-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetCommandAndPrefix()`, (): void => { let data: IDiscordGetCommandAndPrefixData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-command-first-argument.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-command-first-argument.spec.ts index 805584a02..67d9365cf 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-command-first-argument.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-command-first-argument.spec.ts @@ -1,13 +1,13 @@ import { discordGetCommandFirstArgument } from './discord-get-command-first-argument'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandFirstArgumentData } from '../../../interfaces/commands/getters/discord-get-command-first-argument-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetCommandFirstArgument()`, (): void => { let data: IDiscordGetCommandFirstArgumentData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-command-flags.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-command-flags.spec.ts index eb712bcf8..72073d060 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-command-flags.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-command-flags.spec.ts @@ -1,13 +1,13 @@ import { discordGetCommandFlags } from './discord-get-command-flags'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandFlagsData } from '../../../interfaces/commands/getters/discord-get-command-flags-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetCommandFlags()`, (): void => { let data: IDiscordGetCommandFlagsData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-command-with-prefix.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-command-with-prefix.spec.ts index 1aeb617f3..44470ad9d 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-command-with-prefix.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-command-with-prefix.spec.ts @@ -1,13 +1,13 @@ import { discordGetCommandWithPrefix } from './discord-get-command-with-prefix'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandWithPrefix } from '../../../interfaces/commands/getters/discord-get-command-with-prefix'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetCommandWithPrefix()`, (): void => { let data: IDiscordGetCommandWithPrefix; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is $`, (): void => { diff --git a/src/features/discord/messages/functions/commands/getters/discord-get-this-command-with-prefix.spec.ts b/src/features/discord/messages/functions/commands/getters/discord-get-this-command-with-prefix.spec.ts index 54ba6f1e6..065bfa4b3 100644 --- a/src/features/discord/messages/functions/commands/getters/discord-get-this-command-with-prefix.spec.ts +++ b/src/features/discord/messages/functions/commands/getters/discord-get-this-command-with-prefix.spec.ts @@ -1,13 +1,13 @@ import { discordGetThisCommandWithPrefix } from './discord-get-this-command-with-prefix'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetThisCommandWithPrefixData } from '../../../interfaces/commands/getters/discord-get-this-command-with-prefix-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`discordGetThisCommandWithPrefix()`, (): void => { let data: IDiscordGetThisCommandWithPrefixData; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the message is empty`, (): void => { diff --git a/src/features/discord/messages/functions/commands/regexp/discord-get-command-regexp.spec.ts b/src/features/discord/messages/functions/commands/regexp/discord-get-command-regexp.spec.ts index 6774743bc..9f858bd33 100644 --- a/src/features/discord/messages/functions/commands/regexp/discord-get-command-regexp.spec.ts +++ b/src/features/discord/messages/functions/commands/regexp/discord-get-command-regexp.spec.ts @@ -1,7 +1,7 @@ import { discordGetCommandRegexp } from './discord-get-command-regexp'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandRegexpData } from '../../../interfaces/commands/getters/discord-get-command-regexp-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; import xregexp from 'xregexp'; describe(`discordGetCommandRegexp()`, (): void => { @@ -9,7 +9,7 @@ describe(`discordGetCommandRegexp()`, (): void => { let message: string; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-and-flags-regexp.spec.ts b/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-and-flags-regexp.spec.ts index 849ba14c6..fa4a3fdf0 100644 --- a/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-and-flags-regexp.spec.ts +++ b/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-and-flags-regexp.spec.ts @@ -1,7 +1,7 @@ import { discordGetCommandWithFirstArgumentAndFlagsRegexp } from './discord-get-command-with-first-argument-and-flags-regexp'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandWithFirstArgumentAndFlagsRegexpData } from '../../../interfaces/commands/getters/discord-get-command-with-first-argument-and-flags-regexp-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; import xregexp from 'xregexp'; describe(`discordGetCommandWithFirstArgumentAndFlagsRegexp()`, (): void => { @@ -9,7 +9,7 @@ describe(`discordGetCommandWithFirstArgumentAndFlagsRegexp()`, (): void => { let message: string; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-regexp.spec.ts b/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-regexp.spec.ts index 74e948596..27af2e6e5 100644 --- a/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-regexp.spec.ts +++ b/src/features/discord/messages/functions/commands/regexp/discord-get-command-with-first-argument-regexp.spec.ts @@ -1,7 +1,7 @@ import { discordGetCommandWithFirstArgumentRegexp } from './discord-get-command-with-first-argument-regexp'; import { DiscordMessageCommandEnum } from '../../../enums/commands/discord-message-command.enum'; import { IDiscordGetCommandWithFirstArgumentRegexpData } from '../../../interfaces/commands/getters/discord-get-command-with-first-argument-regexp-data'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; import xregexp from 'xregexp'; describe(`discordGetCommandWithFirstArgumentRegexp()`, (): void => { @@ -9,7 +9,7 @@ describe(`discordGetCommandWithFirstArgumentRegexp()`, (): void => { let message: string; beforeEach((): void => { - data = createMock(); + data = createHydratedMock(); }); describe(`when the given prefix is !`, (): void => { diff --git a/src/features/discord/messages/services/command/cookie/services/__mocks__/discord-message-command-cookie.service.ts b/src/features/discord/messages/services/command/cookie/services/__mocks__/discord-message-command-cookie.service.ts index 9749b70b2..28d33c56b 100644 --- a/src/features/discord/messages/services/command/cookie/services/__mocks__/discord-message-command-cookie.service.ts +++ b/src/features/discord/messages/services/command/cookie/services/__mocks__/discord-message-command-cookie.service.ts @@ -3,7 +3,7 @@ import { ServiceNameEnum } from '../../../../../../../../enums/service-name.enum import { IDiscordMessageResponse } from '../../../../../interfaces/discord-message-response'; import { MessageEmbed } from 'discord.js'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; export class DiscordMessageCommandCookieService extends AbstractService { private static _instance: DiscordMessageCommandCookieService; @@ -27,7 +27,7 @@ export class DiscordMessageCommandCookieService extends AbstractService { public getMessageResponse(): IDiscordMessageResponse { return { options: { - embed: createMock(), + embed: createHydratedMock(), split: false, }, response: ``, diff --git a/src/features/discord/messages/services/command/cookie/services/discord-message-command-cookie.service.spec.ts b/src/features/discord/messages/services/command/cookie/services/discord-message-command-cookie.service.spec.ts index 5764e7764..db5f7645b 100644 --- a/src/features/discord/messages/services/command/cookie/services/discord-message-command-cookie.service.spec.ts +++ b/src/features/discord/messages/services/command/cookie/services/discord-message-command-cookie.service.spec.ts @@ -15,7 +15,7 @@ import { DISCORD_MESSAGE_COMMAND_COOKIE_DESCRIPTION_MESSAGES } from '../constant import { DISCORD_MESSAGE_COMMAND_COOKIE_TITLE_MESSAGES } from '../constants/discord-message-command-cookie-title-messages'; import { MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -81,7 +81,7 @@ describe(`DiscordMessageCommandCookieService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandCookieService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -130,7 +130,7 @@ describe(`DiscordMessageCommandCookieService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandCookieService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -157,7 +157,7 @@ describe(`DiscordMessageCommandCookieService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/discord-message-command-cli-error.service.spec.ts b/src/features/discord/messages/services/command/discord-message-command-cli-error.service.spec.ts index 44011d839..5de502860 100644 --- a/src/features/discord/messages/services/command/discord-message-command-cli-error.service.spec.ts +++ b/src/features/discord/messages/services/command/discord-message-command-cli-error.service.spec.ts @@ -7,7 +7,7 @@ import { DiscordSoniaService } from '../../../users/services/discord-sonia.servi import { DiscordMessageConfigService } from '../config/discord-message-config.service'; import { MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandCliErrorService`, (): void => { let service: DiscordMessageCommandCliErrorService; @@ -86,7 +86,7 @@ describe(`DiscordMessageCommandCliErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getCliErrorMessageResponse(); diff --git a/src/features/discord/messages/services/command/discord-message-command.service.spec.ts b/src/features/discord/messages/services/command/discord-message-command.service.spec.ts index 75d1e8e45..2b0a3eb10 100644 --- a/src/features/discord/messages/services/command/discord-message-command.service.spec.ts +++ b/src/features/discord/messages/services/command/discord-message-command.service.spec.ts @@ -11,7 +11,7 @@ import { CoreEventService } from '../../../../core/services/core-event.service'; import { IDiscordMessageResponse } from '../../interfaces/discord-message-response'; import { DiscordMessageConfigService } from '../config/discord-message-config.service'; import { Message } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandService`, (): void => { let service: DiscordMessageCommandService; @@ -357,8 +357,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandVersionServiceHandleResponseSpy = jest .spyOn(discordMessageCommandVersionService, `handleResponse`) @@ -391,8 +391,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandErrorServiceHandleResponseSpy = jest .spyOn(discordMessageCommandErrorService, `handleResponse`) @@ -425,8 +425,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandHelpServiceHandleResponseSpy = jest .spyOn(discordMessageCommandHelpService, `handleResponse`) @@ -459,8 +459,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandCookieServiceResponseSpy = jest .spyOn(discordMessageCommandCookieService, `handleResponse`) @@ -493,8 +493,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandLunchServiceResponseSpy = jest .spyOn(discordMessageCommandLunchService, `handleResponse`) @@ -527,8 +527,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandReleaseNotesServiceResponseSpy = jest .spyOn(discordMessageCommandReleaseNotesService, `handleResponse`) @@ -561,8 +561,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageCommandFeatureServiceResponseSpy = jest .spyOn(discordMessageCommandFeatureService, `handleResponse`) @@ -601,8 +601,8 @@ describe(`DiscordMessageCommandService`, (): void => { beforeEach((): void => { service = DiscordMessageCommandService.getInstance(); - anyDiscordMessage = createMock(); - discordMessageResponse = createMock(); + anyDiscordMessage = createHydratedMock(); + discordMessageResponse = createHydratedMock(); discordMessageConfigServiceGetMessageCommandPrefixSpy.mockReturnValue(`-`); discordMessageCommandVersionServiceHandleResponseSpy = jest diff --git a/src/features/discord/messages/services/command/error/discord-message-command-error.service.spec.ts b/src/features/discord/messages/services/command/error/discord-message-command-error.service.spec.ts index 98f2e424f..ecd088aec 100644 --- a/src/features/discord/messages/services/command/error/discord-message-command-error.service.spec.ts +++ b/src/features/discord/messages/services/command/error/discord-message-command-error.service.spec.ts @@ -11,7 +11,7 @@ import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { DiscordMessageConfigService } from '../../config/discord-message-config.service'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -77,7 +77,7 @@ describe(`DiscordMessageCommandErrorService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandErrorService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -126,7 +126,7 @@ describe(`DiscordMessageCommandErrorService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandErrorService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -147,7 +147,7 @@ describe(`DiscordMessageCommandErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/feature/discord-message-command-feature.service.spec.ts b/src/features/discord/messages/services/command/feature/discord-message-command-feature.service.spec.ts index def68d1a4..1b443ae2b 100644 --- a/src/features/discord/messages/services/command/feature/discord-message-command-feature.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/discord-message-command-feature.service.spec.ts @@ -19,7 +19,7 @@ import { IDiscordMessageResponse } from '../../../interfaces/discord-message-res import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { DiscordMessageConfigService } from '../../config/discord-message-config.service'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -101,7 +101,7 @@ describe(`DiscordMessageCommandFeatureService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -165,29 +165,29 @@ describe(`DiscordMessageCommandFeatureService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, valueOf: _.stubObject(), }); - discordMessageResponse = createMock({ + discordMessageResponse = createHydratedMock({ response: `discordMessageResponse`, }); - getEmptyContentErrorMessageResponse = createMock({ + getEmptyContentErrorMessageResponse = createHydratedMock({ response: `getEmptyContentErrorMessageResponse`, }); - getEmptyFeatureNameErrorMessageResponse = createMock({ + getEmptyFeatureNameErrorMessageResponse = createHydratedMock({ response: `getEmptyFeatureNameErrorMessageResponse`, }); - getWrongFeatureNameErrorMessageResponse = createMock({ + getWrongFeatureNameErrorMessageResponse = createHydratedMock({ response: `getWrongFeatureNameErrorMessageResponse`, }); - getEmptyFlagsErrorMessageResponse = createMock({ + getEmptyFlagsErrorMessageResponse = createHydratedMock({ response: `getEmptyFlagsErrorMessageResponse`, }); - getWrongFlagsErrorMessageResponse = createMock({ + getWrongFlagsErrorMessageResponse = createHydratedMock({ response: `getWrongFlagsErrorMessageResponse`, }); - getDuplicatedFlagsErrorMessageResponse = createMock({ + getDuplicatedFlagsErrorMessageResponse = createHydratedMock({ response: `getDuplicatedFlagsErrorMessageResponse`, }); diff --git a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-disabled.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-disabled.spec.ts index 28ea69c6f..e89ab026c 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-disabled.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-disabled.spec.ts @@ -15,7 +15,7 @@ import { IDiscordCommandFlagSuccess } from '../../../../../../interfaces/command import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { Message } from 'discord.js'; import admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -53,7 +53,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonDisabled(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; @@ -118,7 +118,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -143,7 +143,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -153,7 +153,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -188,7 +188,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -556,7 +556,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -934,8 +934,8 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonDisabled(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -945,7 +945,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -977,7 +977,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -1035,7 +1035,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -1054,7 +1054,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -1072,7 +1072,7 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -1090,9 +1090,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -1113,9 +1113,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -1127,9 +1127,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the channel does not have the noon feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: undefined, }, @@ -1153,9 +1153,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the channel does not have the noon feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: undefined, @@ -1181,9 +1181,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the channel has the noon feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: true, @@ -1209,9 +1209,9 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { describe(`when the channel has the noon feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: false, @@ -1252,11 +1252,11 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => { service = new DiscordMessageCommandFeatureNoonDisabled(); shouldDisable = false; isDisabled = undefined; - firebaseGuild = createMock(); - channel = createMock({ + firebaseGuild = createHydratedMock(); + channel = createHydratedMock({ id: `dummy-channel-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy = jest .spyOn(firebaseGuildsChannelsFeaturesNoonEnabledService, `updateStateByGuildId`) diff --git a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-enabled.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-enabled.spec.ts index 8b8b80400..d6415f29e 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-enabled.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-enabled.spec.ts @@ -15,7 +15,7 @@ import { IDiscordCommandFlagSuccess } from '../../../../../../interfaces/command import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { Message } from 'discord.js'; import admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -53,7 +53,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonEnabled(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; @@ -118,7 +118,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -143,7 +143,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -153,7 +153,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -188,7 +188,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -556,7 +556,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -934,8 +934,8 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonEnabled(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -945,7 +945,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -977,7 +977,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -1035,7 +1035,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -1054,7 +1054,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -1072,7 +1072,7 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -1090,9 +1090,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -1113,9 +1113,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -1127,9 +1127,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the channel does not have the noon feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: undefined, }, @@ -1153,9 +1153,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the channel does not have the noon feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: undefined, @@ -1181,9 +1181,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the channel has the noon feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: true, @@ -1209,9 +1209,9 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { describe(`when the channel has the noon feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: false, @@ -1252,11 +1252,11 @@ describe(`DiscordMessageCommandFeatureNoonEnabled`, (): void => { service = new DiscordMessageCommandFeatureNoonEnabled(); shouldEnable = false; isEnabled = undefined; - firebaseGuild = createMock(); - channel = createMock({ + firebaseGuild = createHydratedMock(); + channel = createHydratedMock({ id: `dummy-channel-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy = jest .spyOn(firebaseGuildsChannelsFeaturesNoonEnabledService, `updateStateByGuildId`) diff --git a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-help.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-help.spec.ts index 216e322a2..6910495b9 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-help.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-help.spec.ts @@ -13,7 +13,7 @@ import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../constants/discord import { DiscordMessageCommandFeatureNoonFlagEnum } from '../enums/discord-message-command-feature-noon-flag.enum'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -42,12 +42,12 @@ describe(`DiscordMessageCommandFeatureNoonHelp`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonHelp(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; discordCommandFlags = DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS; - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); getMessageResponseSpy = jest @@ -122,7 +122,7 @@ describe(`DiscordMessageCommandFeatureNoonHelp`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonHelp(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); discordCommandFlags = DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS; @@ -172,7 +172,7 @@ describe(`DiscordMessageCommandFeatureNoonHelp`, (): void => { describe(`when the message response for the help command was successfully fetched`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, discordCommandFlags); diff --git a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-humanize.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-humanize.spec.ts index 92246f46f..5d03626c2 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-humanize.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-humanize.spec.ts @@ -24,7 +24,7 @@ import { DiscordMessageCommandFeatureNoonHumanizeDisabledMessagesEnum } from '.. import { DiscordMessageCommandFeatureNoonHumanizeEnabledMessagesEnum } from '../enums/discord-message-command-feature-noon-humanize-enabled-messages.enum'; import { Message, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -56,7 +56,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonHumanize(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -106,14 +106,14 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { let firebaseGuildChannelFeatureNoonState: IFirebaseGuildChannelFeatureNoonState; beforeEach((): void => { - firebaseGuildChannelFeatureNoonState = createMock(); + firebaseGuildChannelFeatureNoonState = createHydratedMock(); getStatesSpy.mockResolvedValue(firebaseGuildChannelFeatureNoonState); }); describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -130,7 +130,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -140,7 +140,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -163,7 +163,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -217,7 +217,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -281,8 +281,8 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonHumanize(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -292,7 +292,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -324,7 +324,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -382,7 +382,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -401,7 +401,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -419,7 +419,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -437,9 +437,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -460,9 +460,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -474,9 +474,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the channel does not have the noon feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: undefined, }, @@ -500,9 +500,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the channel does not have the noon feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: undefined, @@ -528,9 +528,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the channel has the noon feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: true, @@ -556,9 +556,9 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the channel has the noon feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: false, @@ -599,7 +599,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonHumanize(); - state = createMock({ + state = createHydratedMock({ isEnabled: true, }); @@ -650,7 +650,7 @@ describe(`DiscordMessageCommandFeatureNoonHumanize`, (): void => { describe(`when the message response for the help command was successfully fetched`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(state); diff --git a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-status.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-status.spec.ts index bdc4f3d0f..caefab012 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-status.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/classes/discord-message-command-feature-noon-status.spec.ts @@ -13,7 +13,7 @@ import { IDiscordMessageResponse } from '../../../../../../interfaces/discord-me import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { DiscordMessageCommandFeatureNoonFlagEnum } from '../enums/discord-message-command-feature-noon-flag.enum'; import { Message } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -39,7 +39,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonStatus(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -96,7 +96,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -113,7 +113,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -123,7 +123,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -146,7 +146,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -200,7 +200,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -264,8 +264,8 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonStatus(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -275,7 +275,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -307,7 +307,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -365,7 +365,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -384,7 +384,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -402,7 +402,7 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -420,9 +420,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -443,9 +443,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -457,9 +457,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the channel does not have the noon feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: undefined, }, @@ -483,9 +483,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the channel does not have the noon feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: undefined, @@ -511,9 +511,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the channel has the noon feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: true, @@ -539,9 +539,9 @@ describe(`DiscordMessageCommandFeatureNoonStatus`, (): void => { describe(`when the channel has the noon feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { noon: { isEnabled: false, diff --git a/src/features/discord/messages/services/command/feature/features/noon/services/discord-message-command-feature-noon.service.spec.ts b/src/features/discord/messages/services/command/feature/features/noon/services/discord-message-command-feature-noon.service.spec.ts index d278b3c5f..5f7e636ef 100644 --- a/src/features/discord/messages/services/command/feature/features/noon/services/discord-message-command-feature-noon.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/noon/services/discord-message-command-feature-noon.service.spec.ts @@ -17,7 +17,7 @@ import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../constants/discord import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import _ from 'lodash'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -134,7 +134,7 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureNoonService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); messageFlags = `--enabled=true -e`; executeAllSpy = jest @@ -185,7 +185,7 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { let discordCommandFlagsResponse: IDiscordCommandFlagsResponse; beforeEach((): void => { - discordCommandFlagsResponse = createMock(); + discordCommandFlagsResponse = createHydratedMock(); executeAllSpy.mockResolvedValue(discordCommandFlagsResponse); }); @@ -194,7 +194,7 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { let discordCommandFlagsSuccess: IDiscordCommandFlagsSuccess; beforeEach((): void => { - discordCommandFlagsSuccess = [createMock()]; + discordCommandFlagsSuccess = [createHydratedMock()]; discordCommandFlagsResponse = discordCommandFlagsSuccess; executeAllSpy.mockResolvedValue(discordCommandFlagsResponse); @@ -210,7 +210,7 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, messageFlags); @@ -352,9 +352,9 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { beforeEach((): void => { discordCommandFlagsSuccess = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; discordCommandFlagsResponse = discordCommandFlagsSuccess; @@ -506,7 +506,7 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { let discordMessageResponses: IDiscordMessageResponse[]; beforeEach((): void => { - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); discordMessageResponses = [discordMessageResponse]; discordCommandFlagsResponse = discordMessageResponses; @@ -530,13 +530,13 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { let discordMessageResponses: IDiscordMessageResponse[]; beforeEach((): void => { - discordMessageResponseA = createMock({ + discordMessageResponseA = createHydratedMock({ response: `dummy-response-a`, }); - discordMessageResponseB = createMock({ + discordMessageResponseB = createHydratedMock({ response: `dummy-response-b`, }); - discordMessageResponseC = createMock({ + discordMessageResponseC = createHydratedMock({ response: `dummy-response-c`, }); discordMessageResponses = [discordMessageResponseA, discordMessageResponseB, discordMessageResponseC]; @@ -566,17 +566,17 @@ describe(`DiscordMessageCommandFeatureNoonService`, (): void => { beforeEach((): void => { discordCommandFlagsSuccess = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; - discordMessageResponseA = createMock({ + discordMessageResponseA = createHydratedMock({ response: `dummy-response-a`, }); - discordMessageResponseB = createMock({ + discordMessageResponseB = createHydratedMock({ response: `dummy-response-b`, }); - discordMessageResponseC = createMock({ + discordMessageResponseC = createHydratedMock({ response: `dummy-response-c`, }); discordMessageResponses = [discordMessageResponseA, discordMessageResponseB, discordMessageResponseC]; diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-disabled.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-disabled.spec.ts index fb93a0a23..b81433b90 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-disabled.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-disabled.spec.ts @@ -16,7 +16,7 @@ import { IDiscordCommandFlagSuccess } from '../../../../../../interfaces/command import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { Message } from 'discord.js'; import admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -56,7 +56,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesDisabled(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; @@ -121,7 +121,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -146,7 +146,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -156,7 +156,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -191,7 +191,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -559,7 +559,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -939,8 +939,8 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesDisabled(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -956,7 +956,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -988,7 +988,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -1046,7 +1046,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -1065,7 +1065,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -1083,7 +1083,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -1101,9 +1101,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -1124,9 +1124,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -1138,9 +1138,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the channel does not have the release notes feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: undefined, }, @@ -1164,9 +1164,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the channel does not have the release notes feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: undefined, @@ -1230,9 +1230,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the channel has the release notes feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: true, @@ -1258,9 +1258,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { describe(`when the channel has the release notes feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: false, @@ -1303,11 +1303,11 @@ describe(`DiscordMessageCommandFeatureReleaseNotesDisabled`, (): void => { service = new DiscordMessageCommandFeatureReleaseNotesDisabled(); shouldDisable = false; isDisabled = undefined; - firebaseGuild = createMock(); - channel = createMock({ + firebaseGuild = createHydratedMock(); + channel = createHydratedMock({ id: `dummy-channel-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsChannelsFeaturesReleaseNotesEnabledServiceUpdateStateByGuildIdSpy = jest .spyOn(firebaseGuildsChannelsFeaturesReleaseNotesEnabledService, `updateStateByGuildId`) diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-enabled.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-enabled.spec.ts index 8ef6ded5d..516bea676 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-enabled.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-enabled.spec.ts @@ -16,7 +16,7 @@ import { IDiscordCommandFlagSuccess } from '../../../../../../interfaces/command import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { Message } from 'discord.js'; import admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -56,7 +56,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesEnabled(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; @@ -121,7 +121,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -146,7 +146,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -156,7 +156,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -191,7 +191,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -559,7 +559,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -939,8 +939,8 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesEnabled(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -956,7 +956,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -988,7 +988,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -1046,7 +1046,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -1065,7 +1065,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -1083,7 +1083,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -1101,9 +1101,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -1124,9 +1124,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -1138,9 +1138,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the channel does not have the release notes feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: undefined, }, @@ -1164,9 +1164,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the channel does not have the release notes feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: undefined, @@ -1230,9 +1230,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the channel has the release notes feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: true, @@ -1258,9 +1258,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { describe(`when the channel has the release notes feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: false, @@ -1303,11 +1303,11 @@ describe(`DiscordMessageCommandFeatureReleaseNotesEnabled`, (): void => { service = new DiscordMessageCommandFeatureReleaseNotesEnabled(); shouldEnable = false; isEnabled = undefined; - firebaseGuild = createMock(); - channel = createMock({ + firebaseGuild = createHydratedMock(); + channel = createHydratedMock({ id: `dummy-channel-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsChannelsFeaturesReleaseNotesEnabledServiceUpdateStateByGuildIdSpy = jest .spyOn(firebaseGuildsChannelsFeaturesReleaseNotesEnabledService, `updateStateByGuildId`) diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-help.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-help.spec.ts index 4be423308..1ba18983b 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-help.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-help.spec.ts @@ -13,7 +13,7 @@ import { DISCORD_MESSAGE_COMMAND_FEATURE_RELEASE_NOTES_FLAGS } from '../constant import { DiscordMessageCommandFeatureReleaseNotesFlagEnum } from '../enums/discord-message-command-feature-release-notes-flag.enum'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -42,12 +42,12 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHelp`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesHelp(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); value = undefined; discordCommandFlags = DISCORD_MESSAGE_COMMAND_FEATURE_RELEASE_NOTES_FLAGS; - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); getMessageResponseSpy = jest @@ -122,7 +122,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHelp`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesHelp(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); discordCommandFlags = DISCORD_MESSAGE_COMMAND_FEATURE_RELEASE_NOTES_FLAGS; @@ -172,7 +172,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHelp`, (): void => { describe(`when the message response for the help command was successfully fetched`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, discordCommandFlags); diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-humanize.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-humanize.spec.ts index f0718d132..2e302e078 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-humanize.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-humanize.spec.ts @@ -25,7 +25,7 @@ import { DiscordMessageCommandFeatureReleaseNotesHumanizeDisabledMessagesEnum } import { DiscordMessageCommandFeatureReleaseNotesHumanizeEnabledMessagesEnum } from '../enums/discord-message-command-feature-release-notes-humanize-enabled-messages.enum'; import { Message, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -59,7 +59,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesHumanize(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -109,14 +109,14 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { let firebaseGuildChannelFeatureReleaseNotesState: IFirebaseGuildChannelFeatureReleaseNotesState; beforeEach((): void => { - firebaseGuildChannelFeatureReleaseNotesState = createMock(); + firebaseGuildChannelFeatureReleaseNotesState = createHydratedMock(); getStatesSpy.mockResolvedValue(firebaseGuildChannelFeatureReleaseNotesState); }); describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -133,7 +133,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -143,7 +143,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -166,7 +166,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -220,7 +220,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -286,8 +286,8 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesHumanize(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -303,7 +303,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -335,7 +335,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -393,7 +393,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -412,7 +412,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -430,7 +430,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -448,9 +448,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -471,9 +471,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -485,9 +485,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the channel does not have the release notes feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: undefined, }, @@ -511,9 +511,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the channel does not have the release notes feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: undefined, @@ -577,9 +577,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the channel has the release notes feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: true, @@ -605,9 +605,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the channel has the release notes feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: false, @@ -650,7 +650,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesHumanize(); - state = createMock({ + state = createHydratedMock({ isEnabled: true, }); @@ -701,7 +701,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesHumanize`, (): void => { describe(`when the message response for the help command was successfully fetched`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(state); diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-status.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-status.spec.ts index 3d8e708a5..f03dc4114 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-status.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/classes/discord-message-command-feature-release-notes-status.spec.ts @@ -17,7 +17,7 @@ import { IDiscordMessageResponse } from '../../../../../../interfaces/discord-me import { IAnyDiscordMessage } from '../../../../../../types/any-discord-message'; import { DiscordMessageCommandFeatureReleaseNotesFlagEnum } from '../enums/discord-message-command-feature-release-notes-flag.enum'; import { Message } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -45,7 +45,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesStatus(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -102,7 +102,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Discord message guild is not valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -119,7 +119,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: {}, id: `dummy-id`, }); @@ -129,7 +129,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Discord message channel is not a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `news`, @@ -152,7 +152,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Discord message channel is a DM channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `dm`, @@ -206,7 +206,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Discord message channel is a text channel`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, type: `text`, @@ -272,8 +272,8 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesStatus(); - anyDiscordMessage = createMock(); - firebaseGuildVFinal = createMock(); + anyDiscordMessage = createHydratedMock(); + firebaseGuildVFinal = createHydratedMock(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); firebaseGuildsStoreQueryGetEntitySpy = jest @@ -289,7 +289,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the given Discord message guild is null`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ guild: null, id: `dummy-id`, }); @@ -321,7 +321,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the given Discord message guild is valid`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { id: `dummy-channel-id`, }, @@ -379,7 +379,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Firebase guilds store channels are empty`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: {}, version: FirebaseGuildVersionEnum.V5, }); @@ -398,7 +398,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Firebase guilds are v1`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -416,7 +416,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the Firebase guilds are v2`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); @@ -434,9 +434,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the given Discord message channel does not exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'bad-dummy-channel-id': createMock({ + 'bad-dummy-channel-id': createHydratedMock({ id: `bad-dummy-channel-id`, }), }, @@ -457,9 +457,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the given Discord message channel exist in the Firebase guilds store channels`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ id: `dummy-channel-id`, }), }, @@ -471,9 +471,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the channel does not have the release notes feature configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: undefined, }, @@ -497,9 +497,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the channel does not have the release notes feature enabled option configured yet`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: undefined, @@ -563,9 +563,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the channel has the release notes feature enabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: true, @@ -594,9 +594,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesStatus`, (): void => { describe(`when the channel has the release notes feature disabled`, (): void => { beforeEach((): void => { - firebaseGuildVFinal = createMock({ + firebaseGuildVFinal = createHydratedMock({ channels: { - 'dummy-channel-id': createMock({ + 'dummy-channel-id': createHydratedMock({ features: { releaseNotes: { isEnabled: false, diff --git a/src/features/discord/messages/services/command/feature/features/release-notes/services/discord-message-command-feature-release-notes.service.spec.ts b/src/features/discord/messages/services/command/feature/features/release-notes/services/discord-message-command-feature-release-notes.service.spec.ts index b8e217a39..209c04466 100644 --- a/src/features/discord/messages/services/command/feature/features/release-notes/services/discord-message-command-feature-release-notes.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/features/release-notes/services/discord-message-command-feature-release-notes.service.spec.ts @@ -17,7 +17,7 @@ import { DISCORD_MESSAGE_COMMAND_FEATURE_RELEASE_NOTES_FLAGS } from '../constant import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import _ from 'lodash'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../../../logger/services/chalk/chalk.service`); @@ -134,7 +134,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureReleaseNotesService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); messageFlags = `--enabled=true -e`; executeAllSpy = jest @@ -187,7 +187,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { let discordCommandFlagsResponse: IDiscordCommandFlagsResponse; beforeEach((): void => { - discordCommandFlagsResponse = createMock(); + discordCommandFlagsResponse = createHydratedMock(); executeAllSpy.mockResolvedValue(discordCommandFlagsResponse); }); @@ -196,7 +196,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { let discordCommandFlagsSuccess: IDiscordCommandFlagsSuccess; beforeEach((): void => { - discordCommandFlagsSuccess = [createMock()]; + discordCommandFlagsSuccess = [createHydratedMock()]; discordCommandFlagsResponse = discordCommandFlagsSuccess; executeAllSpy.mockResolvedValue(discordCommandFlagsResponse); @@ -212,7 +212,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, messageFlags); @@ -358,9 +358,9 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { beforeEach((): void => { discordCommandFlagsSuccess = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; discordCommandFlagsResponse = discordCommandFlagsSuccess; @@ -514,7 +514,7 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { let discordMessageResponses: IDiscordMessageResponse[]; beforeEach((): void => { - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); discordMessageResponses = [discordMessageResponse]; discordCommandFlagsResponse = discordMessageResponses; @@ -538,13 +538,13 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { let discordMessageResponses: IDiscordMessageResponse[]; beforeEach((): void => { - discordMessageResponseA = createMock({ + discordMessageResponseA = createHydratedMock({ response: `dummy-response-a`, }); - discordMessageResponseB = createMock({ + discordMessageResponseB = createHydratedMock({ response: `dummy-response-b`, }); - discordMessageResponseC = createMock({ + discordMessageResponseC = createHydratedMock({ response: `dummy-response-c`, }); discordMessageResponses = [discordMessageResponseA, discordMessageResponseB, discordMessageResponseC]; @@ -574,17 +574,17 @@ describe(`DiscordMessageCommandFeatureReleaseNotesService`, (): void => { beforeEach((): void => { discordCommandFlagsSuccess = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; - discordMessageResponseA = createMock({ + discordMessageResponseA = createHydratedMock({ response: `dummy-response-a`, }); - discordMessageResponseB = createMock({ + discordMessageResponseB = createHydratedMock({ response: `dummy-response-b`, }); - discordMessageResponseC = createMock({ + discordMessageResponseC = createHydratedMock({ response: `dummy-response-c`, }); discordMessageResponses = [discordMessageResponseA, discordMessageResponseB, discordMessageResponseC]; diff --git a/src/features/discord/messages/services/command/feature/services/discord-message-command-feature-empty-content-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/discord-message-command-feature-empty-content-error.service.spec.ts index d0a6bb28e..9b50792d2 100644 --- a/src/features/discord/messages/services/command/feature/services/discord-message-command-feature-empty-content-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/discord-message-command-feature-empty-content-error.service.spec.ts @@ -10,7 +10,7 @@ import { DiscordMessageConfigService } from '../../../config/discord-message-con import { DiscordMessageCommandCliErrorService } from '../../discord-message-command-cli-error.service'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureEmptyContentErrorService`, (): void => { let service: DiscordMessageCommandFeatureEmptyContentErrorService; @@ -116,7 +116,7 @@ describe(`DiscordMessageCommandFeatureEmptyContentErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-empty-feature-name-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-empty-feature-name-error.service.spec.ts index 48a0337b7..4b230720d 100644 --- a/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-empty-feature-name-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-empty-feature-name-error.service.spec.ts @@ -11,7 +11,7 @@ import { DiscordMessageCommandCliErrorService } from '../../../discord-message-c import { DISCORD_MESSAGE_COMMAND_FEATURE_NAMES } from '../../constants/discord-message-command-feature-names'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureEmptyFeatureNameErrorService`, (): void => { let service: DiscordMessageCommandFeatureEmptyFeatureNameErrorService; @@ -79,7 +79,7 @@ describe(`DiscordMessageCommandFeatureEmptyFeatureNameErrorService`, (): void => beforeEach((): void => { service = new DiscordMessageCommandFeatureEmptyFeatureNameErrorService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); commands = [DiscordMessageCommandEnum.COOKIE]; discordMessageCommandCliErrorServiceGetCliErrorMessageResponseSpy = jest.spyOn( @@ -117,7 +117,7 @@ describe(`DiscordMessageCommandFeatureEmptyFeatureNameErrorService`, (): void => it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, commands); diff --git a/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-wrong-feature-name-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-wrong-feature-name-error.service.spec.ts index 5805325ec..f16c317e2 100644 --- a/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-wrong-feature-name-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/feature-names/discord-message-command-feature-wrong-feature-name-error.service.spec.ts @@ -11,7 +11,7 @@ import { DiscordMessageCommandCliErrorService } from '../../../discord-message-c import { DISCORD_MESSAGE_COMMAND_FEATURE_NAMES } from '../../constants/discord-message-command-feature-names'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureWrongFeatureNameErrorService`, (): void => { let service: DiscordMessageCommandFeatureWrongFeatureNameErrorService; @@ -80,7 +80,7 @@ describe(`DiscordMessageCommandFeatureWrongFeatureNameErrorService`, (): void => beforeEach((): void => { service = new DiscordMessageCommandFeatureWrongFeatureNameErrorService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); commands = [DiscordMessageCommandEnum.COOKIE]; featureName = `dummy-feature-name`; @@ -119,7 +119,7 @@ describe(`DiscordMessageCommandFeatureWrongFeatureNameErrorService`, (): void => it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, commands, featureName); diff --git a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-duplicated-flags-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-duplicated-flags-error.service.spec.ts index 9a5dd4155..86affd09e 100644 --- a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-duplicated-flags-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-duplicated-flags-error.service.spec.ts @@ -11,7 +11,7 @@ import { DiscordMessageCommandCliErrorService } from '../../../discord-message-c import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../../features/noon/constants/discord-message-command-feature-noon-flags'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureDuplicatedFlagsErrorService`, (): void => { let service: DiscordMessageCommandFeatureDuplicatedFlagsErrorService; @@ -77,7 +77,7 @@ describe(`DiscordMessageCommandFeatureDuplicatedFlagsErrorService`, (): void => beforeEach((): void => { service = new DiscordMessageCommandFeatureDuplicatedFlagsErrorService(); - flagsDuplicated = createMock(); + flagsDuplicated = createHydratedMock(); discordMessageCommandCliErrorServiceGetCliErrorMessageResponseSpy = jest.spyOn( discordMessageCommandCliErrorService, @@ -112,7 +112,7 @@ describe(`DiscordMessageCommandFeatureDuplicatedFlagsErrorService`, (): void => it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(flagsDuplicated); @@ -131,7 +131,7 @@ describe(`DiscordMessageCommandFeatureDuplicatedFlagsErrorService`, (): void => describe(`when there is one given duplicated flag`, (): void => { beforeEach((): void => { - flagsDuplicated = [createMock()]; + flagsDuplicated = [createHydratedMock()]; }); it(`should return a Discord message response embed with a description indicating that one duplicated flag has been found`, async (): Promise => { @@ -177,9 +177,9 @@ describe(`DiscordMessageCommandFeatureDuplicatedFlagsErrorService`, (): void => describe(`when there is three given duplicated flags`, (): void => { beforeEach((): void => { flagsDuplicated = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; }); diff --git a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-empty-flags-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-empty-flags-error.service.spec.ts index 66de5ad59..1ea354c55 100644 --- a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-empty-flags-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-empty-flags-error.service.spec.ts @@ -12,7 +12,7 @@ import { DiscordMessageCommandFeatureNameEnum } from '../../enums/discord-messag import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../../features/noon/constants/discord-message-command-feature-noon-flags'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureEmptyFlagsErrorService`, (): void => { let service: DiscordMessageCommandFeatureEmptyFlagsErrorService; @@ -80,7 +80,7 @@ describe(`DiscordMessageCommandFeatureEmptyFlagsErrorService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureEmptyFlagsErrorService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); commands = [DiscordMessageCommandEnum.FEATURE]; featureName = DiscordMessageCommandFeatureNameEnum.NOON; @@ -117,7 +117,7 @@ describe(`DiscordMessageCommandFeatureEmptyFlagsErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(anyDiscordMessage, commands, featureName); diff --git a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-opposite-flags-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-opposite-flags-error.service.spec.ts index 7a082d620..82123c333 100644 --- a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-opposite-flags-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-opposite-flags-error.service.spec.ts @@ -11,7 +11,7 @@ import { DiscordMessageCommandCliErrorService } from '../../../discord-message-c import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../../features/noon/constants/discord-message-command-feature-noon-flags'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureOppositeFlagsErrorService`, (): void => { let service: DiscordMessageCommandFeatureOppositeFlagsErrorService; @@ -77,7 +77,7 @@ describe(`DiscordMessageCommandFeatureOppositeFlagsErrorService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureOppositeFlagsErrorService(); - oppositeFlags = createMock(); + oppositeFlags = createHydratedMock(); discordMessageCommandCliErrorServiceGetCliErrorMessageResponseSpy = jest.spyOn( discordMessageCommandCliErrorService, @@ -112,7 +112,7 @@ describe(`DiscordMessageCommandFeatureOppositeFlagsErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(oppositeFlags); @@ -131,7 +131,7 @@ describe(`DiscordMessageCommandFeatureOppositeFlagsErrorService`, (): void => { describe(`when there is one given opposite flag`, (): void => { beforeEach((): void => { - oppositeFlags = [createMock()]; + oppositeFlags = [createHydratedMock()]; }); it(`should return a Discord message response embed with a description indicating that one opposite flag has been found`, async (): Promise => { @@ -177,9 +177,9 @@ describe(`DiscordMessageCommandFeatureOppositeFlagsErrorService`, (): void => { describe(`when there is three given opposite flags`, (): void => { beforeEach((): void => { oppositeFlags = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; }); diff --git a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-wrong-flags-error.service.spec.ts b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-wrong-flags-error.service.spec.ts index 9e8f9dacd..0cd50f1ad 100644 --- a/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-wrong-flags-error.service.spec.ts +++ b/src/features/discord/messages/services/command/feature/services/flags/discord-message-command-feature-wrong-flags-error.service.spec.ts @@ -11,7 +11,7 @@ import { DiscordMessageCommandCliErrorService } from '../../../discord-message-c import { DISCORD_MESSAGE_COMMAND_FEATURE_NOON_FLAGS } from '../../features/noon/constants/discord-message-command-feature-noon-flags'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageCommandFeatureWrongFlagsErrorService`, (): void => { let service: DiscordMessageCommandFeatureWrongFlagsErrorService; @@ -77,7 +77,7 @@ describe(`DiscordMessageCommandFeatureWrongFlagsErrorService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandFeatureWrongFlagsErrorService(); - flagsErrors = createMock(); + flagsErrors = createHydratedMock(); discordMessageCommandCliErrorServiceGetCliErrorMessageResponseSpy = jest.spyOn( discordMessageCommandCliErrorService, @@ -112,7 +112,7 @@ describe(`DiscordMessageCommandFeatureWrongFlagsErrorService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(flagsErrors); @@ -131,7 +131,7 @@ describe(`DiscordMessageCommandFeatureWrongFlagsErrorService`, (): void => { describe(`when there is one given flag error`, (): void => { beforeEach((): void => { - flagsErrors = [createMock()]; + flagsErrors = [createHydratedMock()]; }); it(`should return a Discord message response embed with a description indicating that one error has been found`, async (): Promise => { @@ -166,9 +166,9 @@ describe(`DiscordMessageCommandFeatureWrongFlagsErrorService`, (): void => { describe(`when there is three given flags errors`, (): void => { beforeEach((): void => { flagsErrors = [ - createMock(), - createMock(), - createMock(), + createHydratedMock(), + createHydratedMock(), + createHydratedMock(), ]; }); diff --git a/src/features/discord/messages/services/command/help/discord-message-command-help.service.spec.ts b/src/features/discord/messages/services/command/help/discord-message-command-help.service.spec.ts index 5438ae26f..f7589bfdc 100644 --- a/src/features/discord/messages/services/command/help/discord-message-command-help.service.spec.ts +++ b/src/features/discord/messages/services/command/help/discord-message-command-help.service.spec.ts @@ -12,7 +12,7 @@ import { DiscordMessageConfigService } from '../../config/discord-message-config import { DiscordMessageHelpService } from '../../helpers/discord-message-help.service'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -80,7 +80,7 @@ describe(`DiscordMessageCommandHelpService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandHelpService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -170,7 +170,7 @@ describe(`DiscordMessageCommandHelpService`, (): void => { describe(`when the message response for the help command was successfully fetched`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/lunch/services/discord-message-command-lunch.service.spec.ts b/src/features/discord/messages/services/command/lunch/services/discord-message-command-lunch.service.spec.ts index 87d289624..f7c9d52fa 100644 --- a/src/features/discord/messages/services/command/lunch/services/discord-message-command-lunch.service.spec.ts +++ b/src/features/discord/messages/services/command/lunch/services/discord-message-command-lunch.service.spec.ts @@ -15,7 +15,7 @@ import { DISCORD_MESSAGE_COMMAND_LUNCH_DESCRIPTION_MESSAGES } from '../constants import { DISCORD_MESSAGE_COMMAND_LUNCH_TITLE_MESSAGES } from '../constants/discord-message-command-lunch-title-messages'; import { MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -81,7 +81,7 @@ describe(`DiscordMessageCommandLunchService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandLunchService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -152,7 +152,7 @@ describe(`DiscordMessageCommandLunchService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/release-notes/discord-message-command-release-notes.service.spec.ts b/src/features/discord/messages/services/command/release-notes/discord-message-command-release-notes.service.spec.ts index edd8c16c8..7b1b751e5 100644 --- a/src/features/discord/messages/services/command/release-notes/discord-message-command-release-notes.service.spec.ts +++ b/src/features/discord/messages/services/command/release-notes/discord-message-command-release-notes.service.spec.ts @@ -14,7 +14,7 @@ import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { DiscordMessageConfigService } from '../../config/discord-message-config.service'; import { MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -84,7 +84,7 @@ describe(`DiscordMessageCommandReleaseNotesService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandReleaseNotesService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -210,7 +210,7 @@ describe(`DiscordMessageCommandReleaseNotesService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/command/version/discord-message-command-version.service.spec.ts b/src/features/discord/messages/services/command/version/discord-message-command-version.service.spec.ts index dd22dae5e..1217ccc01 100644 --- a/src/features/discord/messages/services/command/version/discord-message-command-version.service.spec.ts +++ b/src/features/discord/messages/services/command/version/discord-message-command-version.service.spec.ts @@ -16,7 +16,7 @@ import { IAnyDiscordMessage } from '../../../types/any-discord-message'; import { DiscordMessageConfigService } from '../../config/discord-message-config.service'; import { EmbedFieldData, MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -88,7 +88,7 @@ describe(`DiscordMessageCommandVersionService`, (): void => { beforeEach((): void => { service = new DiscordMessageCommandVersionService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -186,7 +186,7 @@ describe(`DiscordMessageCommandVersionService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/discord-message.service.spec.ts b/src/features/discord/messages/services/discord-message.service.spec.ts index 10321dc22..7efa0e6b9 100644 --- a/src/features/discord/messages/services/discord-message.service.spec.ts +++ b/src/features/discord/messages/services/discord-message.service.spec.ts @@ -16,8 +16,8 @@ import { DiscordSoniaService } from '../../users/services/discord-sonia.service' import { ISonia } from '../../users/types/sonia'; import { IDiscordMessageResponse } from '../interfaces/discord-message-response'; import { IAnyDiscordMessage } from '../types/any-discord-message'; -import { Client, MessageOptions } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { Client } from 'discord.js'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -100,10 +100,10 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { service = new DiscordMessageService(); discordClientServiceGetClientOnMock = jest.fn(); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue(client); @@ -137,7 +137,7 @@ describe(`DiscordMessageService`, (): void => { listener(anyDiscordMessage); } ); - client = createMock({ + client = createHydratedMock({ on: discordClientServiceGetClientOnMock, }); @@ -178,7 +178,7 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { service = new DiscordMessageService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -382,7 +382,7 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { service = new DiscordMessageService(); anyDiscordMessageChannelSendMock = jest.fn().mockRejectedValue(new Error(`Fake test error: send`)); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -391,7 +391,7 @@ describe(`DiscordMessageService`, (): void => { }, id: `dummy-id`, }); - discordMessageResponse = createMock({ + discordMessageResponse = createHydratedMock({ options: { split: false, }, @@ -424,7 +424,7 @@ describe(`DiscordMessageService`, (): void => { discordAuthorServiceIsValidSpy = jest.spyOn(discordAuthorService, `isValid`).mockImplementation(); discordMentionServiceIsValidSpy = jest.spyOn(discordMentionService, `isValid`).mockImplementation(); discordMentionServiceIsForEveryone = jest.spyOn(discordMentionService, `isForEveryone`).mockImplementation(); - jest.spyOn(discordSoniaService, `getSonia`).mockReturnValue(createMock()); + jest.spyOn(discordSoniaService, `getSonia`).mockReturnValue(createHydratedMock()); discordSoniaServiceIsValidSpy = jest.spyOn(discordSoniaService, `isValid`).mockImplementation(); discordMentionServiceIsUserMentionedSpy = jest .spyOn(discordMentionService, `isUserMentioned`) @@ -775,16 +775,17 @@ describe(`DiscordMessageService`, (): void => { ); expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledTimes(2); - expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledWith(`dummy-response`, { - split: false, - } as MessageOptions); + expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledWith( + `dummy-response`, + discordMessageResponse.options + ); }); describe(`when the message was not successfully sent`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.reject(new Error(`Message sending error`))); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -834,7 +835,7 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.resolve()); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -887,19 +888,19 @@ describe(`DiscordMessageService`, (): void => { let discordMessageResponseC: IDiscordMessageResponse; beforeEach((): void => { - discordMessageResponseA = createMock({ + discordMessageResponseA = createHydratedMock({ options: { split: false, }, response: `dummy-response-a`, }); - discordMessageResponseB = createMock({ + discordMessageResponseB = createHydratedMock({ options: { split: false, }, response: `dummy-response-b`, }); - discordMessageResponseC = createMock({ + discordMessageResponseC = createHydratedMock({ options: { split: false, }, @@ -979,22 +980,28 @@ describe(`DiscordMessageService`, (): void => { ); expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledTimes(6); - expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith(1, `dummy-response-a`, { - split: false, - } as MessageOptions); - expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith(2, `dummy-response-b`, { - split: false, - } as MessageOptions); - expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith(3, `dummy-response-c`, { - split: false, - } as MessageOptions); + expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith( + 1, + `dummy-response-a`, + discordMessageResponseA.options + ); + expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith( + 2, + `dummy-response-b`, + discordMessageResponseB.options + ); + expect(anyDiscordMessageChannelSendMock).toHaveBeenNthCalledWith( + 3, + `dummy-response-c`, + discordMessageResponseC.options + ); }); describe(`when the messages were not successfully sent`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.reject(new Error(`Message sending error`))); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -1055,7 +1062,7 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.resolve()); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -1251,16 +1258,17 @@ describe(`DiscordMessageService`, (): void => { ); expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledTimes(2); - expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledWith(`dummy-response`, { - split: false, - } as MessageOptions); + expect(anyDiscordMessageChannelSendMock).toHaveBeenCalledWith( + `dummy-response`, + discordMessageResponse.options + ); }); describe(`when the message was not successfully sent`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.reject(new Error(`Message sending error`))); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, @@ -1308,7 +1316,7 @@ describe(`DiscordMessageService`, (): void => { beforeEach((): void => { anyDiscordMessageChannelSendMock.mockReturnValue(Promise.resolve()); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ channel: { send: anyDiscordMessageChannelSendMock, }, diff --git a/src/features/discord/messages/services/helpers/discord-message-help.service.spec.ts b/src/features/discord/messages/services/helpers/discord-message-help.service.spec.ts index b97c10986..222def032 100644 --- a/src/features/discord/messages/services/helpers/discord-message-help.service.spec.ts +++ b/src/features/discord/messages/services/helpers/discord-message-help.service.spec.ts @@ -7,7 +7,7 @@ import { DiscordSoniaService } from '../../../users/services/discord-sonia.servi import { DiscordMessageConfigService } from '../config/discord-message-config.service'; import { MessageEmbedAuthor, MessageEmbedFooter, MessageEmbedThumbnail } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -88,7 +88,7 @@ describe(`DiscordMessageHelpService`, (): void => { it(`should return a Discord message response embed with an author`, async (): Promise => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = await service.getMessageResponse(); diff --git a/src/features/discord/messages/services/responses/discord-message-any-question-pineapple-pizza.service.spec.ts b/src/features/discord/messages/services/responses/discord-message-any-question-pineapple-pizza.service.spec.ts index 2dcfc778e..c1279953c 100644 --- a/src/features/discord/messages/services/responses/discord-message-any-question-pineapple-pizza.service.spec.ts +++ b/src/features/discord/messages/services/responses/discord-message-any-question-pineapple-pizza.service.spec.ts @@ -3,7 +3,7 @@ import { ServiceNameEnum } from '../../../../../enums/service-name.enum'; import { CoreEventService } from '../../../../core/services/core-event.service'; import { IAnyDiscordMessage } from '../../types/any-discord-message'; import { DiscordMessageContentService } from '../helpers/discord-message-content.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageAnyQuestionPineapplePizzaService`, (): void => { let service: DiscordMessageAnyQuestionPineapplePizzaService; @@ -237,7 +237,7 @@ describe(`DiscordMessageAnyQuestionPineapplePizzaService`, (): void => { beforeEach((): void => { service = new DiscordMessageAnyQuestionPineapplePizzaService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ content: `dummy-content`, }); diff --git a/src/features/discord/messages/services/responses/discord-message-hotel-trivago.service.spec.ts b/src/features/discord/messages/services/responses/discord-message-hotel-trivago.service.spec.ts index 343f96ec9..f733cb4fa 100644 --- a/src/features/discord/messages/services/responses/discord-message-hotel-trivago.service.spec.ts +++ b/src/features/discord/messages/services/responses/discord-message-hotel-trivago.service.spec.ts @@ -5,7 +5,7 @@ import { DISCORD_MESSAGE_HOTEL_TRIVAGO_RESPONSE_MESSAGES } from '../../constants import { IDiscordMessageHotelTrivagoResponseMessage } from '../../interfaces/discord-message-hotel-trivago-response-message'; import { IAnyDiscordMessage } from '../../types/any-discord-message'; import { DiscordMessageContentService } from '../helpers/discord-message-content.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageHotelTrivagoService`, (): void => { let service: DiscordMessageHotelTrivagoService; @@ -212,7 +212,7 @@ describe(`DiscordMessageHotelTrivagoService`, (): void => { beforeEach((): void => { service = new DiscordMessageHotelTrivagoService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ content: `dummy-content`, }); diff --git a/src/features/discord/messages/services/responses/discord-message-ping-pong.service.spec.ts b/src/features/discord/messages/services/responses/discord-message-ping-pong.service.spec.ts index b676cdcf6..92f466541 100644 --- a/src/features/discord/messages/services/responses/discord-message-ping-pong.service.spec.ts +++ b/src/features/discord/messages/services/responses/discord-message-ping-pong.service.spec.ts @@ -5,7 +5,7 @@ import { DISCORD_MESSAGE_PING_PONG_RESPONSE_MESSAGES } from '../../constants/dis import { IDiscordMessagePingPongResponseMessage } from '../../interfaces/discord-message-ping-pong-response-message'; import { IAnyDiscordMessage } from '../../types/any-discord-message'; import { DiscordMessageContentService } from '../helpers/discord-message-content.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessagePingPongService`, (): void => { let service: DiscordMessagePingPongService; @@ -212,7 +212,7 @@ describe(`DiscordMessagePingPongService`, (): void => { beforeEach((): void => { service = new DiscordMessagePingPongService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ content: `dummy-content`, }); diff --git a/src/features/discord/messages/services/responses/discord-message-simple-basic.service.spec.ts b/src/features/discord/messages/services/responses/discord-message-simple-basic.service.spec.ts index afa32084f..909f7aab0 100644 --- a/src/features/discord/messages/services/responses/discord-message-simple-basic.service.spec.ts +++ b/src/features/discord/messages/services/responses/discord-message-simple-basic.service.spec.ts @@ -3,7 +3,7 @@ import { ServiceNameEnum } from '../../../../../enums/service-name.enum'; import { CoreEventService } from '../../../../core/services/core-event.service'; import { IAnyDiscordMessage } from '../../types/any-discord-message'; import { DiscordMessageContentService } from '../helpers/discord-message-content.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageSimpleBasicService`, (): void => { let service: DiscordMessageSimpleBasicService; @@ -279,7 +279,7 @@ describe(`DiscordMessageSimpleBasicService`, (): void => { beforeEach((): void => { service = new DiscordMessageSimpleBasicService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ content: `dummy-content`, }); diff --git a/src/features/discord/messages/services/rights/discord-message-rights.service.spec.ts b/src/features/discord/messages/services/rights/discord-message-rights.service.spec.ts index a59de8b08..04f4b9c0e 100644 --- a/src/features/discord/messages/services/rights/discord-message-rights.service.spec.ts +++ b/src/features/discord/messages/services/rights/discord-message-rights.service.spec.ts @@ -4,7 +4,7 @@ import { AppConfigService } from '../../../../app/services/config/app-config.ser import { CoreEventService } from '../../../../core/services/core-event.service'; import { DiscordSoniaConfigService } from '../../../users/services/config/discord-sonia-config.service'; import { Guild } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordMessageDmService`, (): void => { let service: DiscordMessageRightsService; @@ -65,7 +65,7 @@ describe(`DiscordMessageDmService`, (): void => { beforeEach((): void => { service = new DiscordMessageRightsService(); - guild = createMock(); + guild = createHydratedMock(); appConfigServiceIsProductionSpy = jest.spyOn(appConfigService, `isProduction`).mockImplementation(); discordSoniaConfigServiceIsGuildWhitelistedInDevSpy = jest diff --git a/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count-message-response.service.spec.ts b/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count-message-response.service.spec.ts index 07c3a8147..89b39e98d 100644 --- a/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count-message-response.service.spec.ts +++ b/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count-message-response.service.spec.ts @@ -8,7 +8,7 @@ import { DiscordSoniaService } from '../../../users/services/discord-sonia.servi import { DiscordMessageCommandFeatureNoonConfigService } from '../command/feature/features/noon/services/config/discord-message-command-feature-noon-config.service'; import { MessageEmbedAuthor } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -98,7 +98,7 @@ describe(`DiscordMessageScheduleNoonCountMessageResponseService`, (): void => { it(`should return a message response with an embed author`, (): void => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = service.getMessageResponse(totalGuildCount, guildCount, channelCount); diff --git a/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count.service.spec.ts b/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count.service.spec.ts index f2d3ca6b4..35f3197d5 100644 --- a/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count.service.spec.ts +++ b/src/features/discord/messages/services/schedule/discord-message-schedule-noon-count.service.spec.ts @@ -8,7 +8,7 @@ import { IDiscordGuildSoniaSendMessageToChannel } from '../../../guilds/interfac import { DiscordGuildSoniaService } from '../../../guilds/services/discord-guild-sonia.service'; import { IDiscordMessageResponse } from '../../interfaces/discord-message-response'; import { Message } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -75,7 +75,7 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { beforeEach((): void => { service = new DiscordMessageScheduleNoonCountService(); - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); discordGuildSoniaServiceSendMessageToChannelSpy = jest @@ -232,7 +232,7 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { describe(`when the given guild messages is an array with one array of one message`, (): void => { beforeEach((): void => { - guildMessages = [[createMock()]]; + guildMessages = [[createHydratedMock()]]; }); it(`should log that one noon message was sent for one guild of one`, (): void => { @@ -250,7 +250,7 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { describe(`when the given guild messages is an array with two arrays of one message`, (): void => { beforeEach((): void => { - guildMessages = [[createMock()], [createMock()]]; + guildMessages = [[createHydratedMock()], [createHydratedMock()]]; }); it(`should log that two noon messages were sent for two guilds of two`, (): void => { @@ -271,10 +271,10 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { guildMessages = [ [], [undefined], - [createMock()], + [createHydratedMock()], [undefined, undefined], - [createMock(), undefined], - [createMock(), createMock()], + [createHydratedMock(), undefined], + [createHydratedMock(), createHydratedMock()], ]; }); @@ -296,10 +296,10 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { guildMessages = [ [], [undefined], - [createMock()], + [createHydratedMock()], [undefined, undefined], - [createMock(), undefined], - [createMock(), createMock()], + [createHydratedMock(), undefined], + [createHydratedMock(), createHydratedMock()], ]; service.countChannelsAndGuilds(guildMessages); @@ -313,10 +313,10 @@ describe(`DiscordMessageScheduleNoonCountService`, (): void => { guildMessages = [ [], [undefined], - [createMock()], + [createHydratedMock()], [undefined, undefined], - [createMock(), undefined], - [createMock(), createMock()], + [createHydratedMock(), undefined], + [createHydratedMock(), createHydratedMock()], ]; service.countChannelsAndGuilds(guildMessages); diff --git a/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.spec.ts b/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.spec.ts index cfd64ce61..267ad670b 100644 --- a/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.spec.ts +++ b/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.spec.ts @@ -28,7 +28,7 @@ import { Client, Collection, Guild, GuildChannel, Message, TextChannel } from 'd import moment from 'moment-timezone'; import * as NodeScheduleModule from 'node-schedule'; import { noop } from 'rxjs'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; let time: number = new Date(`2020-01-02T02:00:00Z`).getTime(); @@ -159,7 +159,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { .spyOn(GetEveryHourScheduleRuleModule, `getEveryHourScheduleRule`) .mockReturnValue(`dummy-schedule`); service = new DiscordMessageScheduleNoonService(); - job = createMock({ + job = createHydratedMock({ reschedule: jobRescheduleMock, }); @@ -302,7 +302,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { beforeEach((): void => { service = new DiscordMessageScheduleNoonService(); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-guild-id`, }); @@ -427,7 +427,10 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the Firebase guild data is a Firebase guild but not up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ + channels: undefined, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V3, }); @@ -457,8 +460,10 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the Firebase guild data is a Firebase guild up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ - channels: {}, + firebaseGuild = createHydratedMock({ + channels: undefined, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V5, }); @@ -479,8 +484,10 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the Firebase guild has no channel`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ - channels: {}, + firebaseGuild = createHydratedMock({ + channels: undefined, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V5, }); @@ -500,13 +507,17 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let channel: IFirebaseGuildChannelVFinal; beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ + features: undefined, id: `one`, + version: FirebaseGuildChannelVersionEnum.V2, }); - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { one: channel, }, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V5, }); @@ -528,17 +539,23 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let channel2: IFirebaseGuildChannelVFinal; beforeEach((): void => { - channel1 = createMock({ + channel1 = createHydratedMock({ + features: undefined, id: `one`, + version: FirebaseGuildChannelVersionEnum.V2, }); - channel2 = createMock({ + channel2 = createHydratedMock({ + features: undefined, id: `two`, + version: FirebaseGuildChannelVersionEnum.V2, }); - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { one: channel1, two: channel2, }, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V5, }); @@ -573,7 +590,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMessageByChannelSpy.mockResolvedValue(message); }); @@ -613,10 +630,10 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { beforeEach((): void => { service = new DiscordMessageScheduleNoonService(); - channel = createMock(); - firebaseGuild = createMock(); + channel = createHydratedMock(); + firebaseGuild = createHydratedMock(); guildChannelsGetMock = jest.fn().mockImplementation(); - guild = createMock({ + guild = createHydratedMock({ channels: { cache: { get: guildChannelsGetMock, @@ -636,7 +653,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the given Firebase guild channel id is undefined`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ id: undefined, }); }); @@ -658,7 +675,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the given Firebase guild channel id is valid`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ id: `dummy-channel-id`, }); }); @@ -666,7 +683,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the given Firebase guild has a valid noon feature`, (): void => { describe(`when the given Firebase guild has a valid noon feature disabled`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-channel-id': { features: { @@ -702,7 +719,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the given Firebase guild has a valid noon feature enabled`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-channel-id': { features: { @@ -770,7 +787,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let guildChannel: GuildChannel; beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, }); @@ -820,7 +837,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMessageResponseSpy.mockResolvedValue(message); }); @@ -849,7 +866,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { service = new DiscordMessageScheduleNoonService(); discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: ({ forEach: noop, @@ -969,7 +986,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when there is no guild`, (): void => { beforeEach((): void => { discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: ({ forEach: noop, @@ -994,12 +1011,12 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let guild: Guild; beforeEach((): void => { - guild = createMock({ + guild = createHydratedMock({ id: `dummy-guild-id`, }); discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: { forEach: (callback): void => callback(guild, `key`, new Map()), @@ -1044,7 +1061,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let messages: Message[]; beforeEach((): void => { - messages = [createMock(), createMock()]; + messages = [createHydratedMock(), createHydratedMock()]; sendMessageSpy.mockResolvedValue(messages); }); @@ -1065,15 +1082,15 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let guild2: Guild; beforeEach((): void => { - guild1 = createMock({ + guild1 = createHydratedMock({ id: `dummy-guild-id-1`, }); - guild2 = createMock({ + guild2 = createHydratedMock({ id: `dummy-guild-id-2`, }); discordClientServiceGetClientSpy = jest.spyOn(discordClientService, `getClient`).mockReturnValue( - createMock({ + createHydratedMock({ guilds: { cache: { forEach(callback): void { @@ -1126,7 +1143,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let messages: Message[]; beforeEach((): void => { - messages = [createMock(), createMock()]; + messages = [createHydratedMock(), createHydratedMock()]; sendMessageSpy.mockResolvedValue(messages); }); @@ -1156,10 +1173,10 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { beforeEach((): void => { service = new DiscordMessageScheduleNoonService(); - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, }); - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); @@ -1173,7 +1190,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { describe(`when the given guild channel is not writable`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, isText(): false { return false; @@ -1201,7 +1218,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { beforeEach((): void => { sendMock = jest.fn().mockRejectedValue(new Error(`send error`)); - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, isText(): true { return true; @@ -1288,7 +1305,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMock.mockResolvedValue(message); }); @@ -1339,7 +1356,7 @@ describe(`DiscordMessageScheduleNoonService`, (): void => { beforeEach((): void => { service = new DiscordMessageScheduleNoonService(); - (service as any)._job = createMock({ + (service as any)._job = createHydratedMock({ nextInvocation(): Date { return moment().toDate(); }, diff --git a/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.ts b/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.ts index d817984c8..2c6fd6d77 100644 --- a/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.ts +++ b/src/features/discord/messages/services/schedule/discord-message-schedule-noon.service.ts @@ -72,7 +72,7 @@ export class DiscordMessageScheduleNoonService extends AbstractService { return Promise.all( _.map( - firebaseGuild.channels, + _.compact(_.values(firebaseGuild.channels)), (channel: Readonly): Promise => this.sendMessageByChannel(channel, firebaseGuild, guild).catch((): Promise => Promise.resolve()) ) diff --git a/src/features/discord/messages/services/types/discord-message-dm.service.spec.ts b/src/features/discord/messages/services/types/discord-message-dm.service.spec.ts index 54ccb0006..6c360683d 100644 --- a/src/features/discord/messages/services/types/discord-message-dm.service.spec.ts +++ b/src/features/discord/messages/services/types/discord-message-dm.service.spec.ts @@ -12,7 +12,7 @@ import { DiscordMessageAuthorService } from '../responses/discord-message-author import { DiscordMessageHotelTrivagoService } from '../responses/discord-message-hotel-trivago.service'; import { DiscordMessagePingPongService } from '../responses/discord-message-ping-pong.service'; import { DiscordMessageSimpleBasicService } from '../responses/discord-message-simple-basic.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -87,7 +87,7 @@ describe(`DiscordMessageDmService`, (): void => { beforeEach((): void => { service = new DiscordMessageDmService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ author: { id: `dummy-author-id`, }, @@ -155,7 +155,7 @@ describe(`DiscordMessageDmService`, (): void => { beforeEach((): void => { service = new DiscordMessageDmService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ content: `dummy-content`, id: `dummy-id`, }); diff --git a/src/features/discord/messages/services/types/discord-message-text.service.spec.ts b/src/features/discord/messages/services/types/discord-message-text.service.spec.ts index 97bccd27a..89f0d484a 100644 --- a/src/features/discord/messages/services/types/discord-message-text.service.spec.ts +++ b/src/features/discord/messages/services/types/discord-message-text.service.spec.ts @@ -19,7 +19,7 @@ import { DiscordMessageHotelTrivagoService } from '../responses/discord-message- import { DiscordMessagePingPongService } from '../responses/discord-message-ping-pong.service'; import { DiscordMessageSimpleBasicService } from '../responses/discord-message-simple-basic.service'; import { Message, PartialMessage } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -103,7 +103,7 @@ describe(`DiscordMessageTextService`, (): void => { beforeEach((): void => { service = new DiscordMessageTextService(); - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); discordAuthorServiceIsValidSpy = jest.spyOn(discordAuthorService, `isValid`).mockImplementation(); discordMentionServiceIsValidSpy = jest.spyOn(discordMentionService, `isValid`).mockImplementation(); @@ -191,7 +191,7 @@ describe(`DiscordMessageTextService`, (): void => { beforeEach((): void => { service = new DiscordMessageTextService(); - discordMessage = createMock({ + discordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -323,7 +323,7 @@ describe(`DiscordMessageTextService`, (): void => { let sonia: ISonia; beforeEach((): void => { - sonia = createMock(); + sonia = createHydratedMock(); discordSoniaServiceGetSoniaSpy.mockReturnValue(sonia); discordSoniaServiceIsValidSpy.mockReturnValue(true); @@ -382,7 +382,7 @@ describe(`DiscordMessageTextService`, (): void => { beforeEach((): void => { service = new DiscordMessageTextService(); - anyDiscordMessage = createMock({ + anyDiscordMessage = createHydratedMock({ id: `dummy-id`, }); @@ -409,7 +409,7 @@ describe(`DiscordMessageTextService`, (): void => { describe(`when the given message is a partial message`, (): void => { beforeEach((): void => { - anyDiscordMessage = createMock(); + anyDiscordMessage = createHydratedMock(); }); it(`should throw an error about not being a valid message`, async (): Promise => { @@ -476,7 +476,7 @@ describe(`DiscordMessageTextService`, (): void => { beforeEach((): void => { service = new DiscordMessageTextService(); - discordMessage = createMock({ + discordMessage = createHydratedMock({ content: `dummy-content`, id: `dummy-id`, }); diff --git a/src/features/discord/services/discord-client.service.spec.ts b/src/features/discord/services/discord-client.service.spec.ts index 1ea52995c..262727b6b 100644 --- a/src/features/discord/services/discord-client.service.spec.ts +++ b/src/features/discord/services/discord-client.service.spec.ts @@ -3,7 +3,7 @@ import { ServiceNameEnum } from '../../../enums/service-name.enum'; import { CoreEventService } from '../../core/services/core-event.service'; import { Client } from 'discord.js'; import { take } from 'rxjs/operators'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordClientService`, (): void => { let service: DiscordClientService; @@ -71,7 +71,7 @@ describe(`DiscordClientService`, (): void => { beforeEach((): void => { service = new DiscordClientService(); - client = createMock(); + client = createHydratedMock(); }); describe(`when the Client does not exist`, (): void => { diff --git a/src/features/discord/services/discord.service.spec.ts b/src/features/discord/services/discord.service.spec.ts index 5720ad24d..b43b6e607 100644 --- a/src/features/discord/services/discord.service.spec.ts +++ b/src/features/discord/services/discord.service.spec.ts @@ -14,7 +14,7 @@ import { DiscordMessageService } from '../messages/services/discord-message.serv import { DiscordMessageScheduleNoonService } from '../messages/services/schedule/discord-message-schedule-noon.service'; import { DiscordSoniaService } from '../users/services/discord-sonia.service'; import { Presence } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordService`, (): void => { let service: DiscordService; @@ -97,16 +97,16 @@ describe(`DiscordService`, (): void => { beforeEach((): void => { service = new DiscordService(); - discordLoggerService = createMock(); - discordGuildService = createMock(); - discordGuildMemberAddService = createMock(); - discordGuildCreateService = createMock(); - discordMessageService = createMock(); - discordAuthenticationService = createMock(); - discordMessageScheduleNoonService = createMock(); - discordGuildSoniaService = createMock(); - discordActivitySoniaService = createMock(); - discordSoniaEmotionalStateService = createMock(); + discordLoggerService = createHydratedMock(); + discordGuildService = createHydratedMock(); + discordGuildMemberAddService = createHydratedMock(); + discordGuildCreateService = createHydratedMock(); + discordMessageService = createHydratedMock(); + discordAuthenticationService = createHydratedMock(); + discordMessageScheduleNoonService = createHydratedMock(); + discordGuildSoniaService = createHydratedMock(); + discordActivitySoniaService = createHydratedMock(); + discordSoniaEmotionalStateService = createHydratedMock(); discordSoniaServiceGetInstanceSpy = jest.spyOn(DiscordSoniaService, `getInstance`); discordLoggerServiceGetInstanceSpy = jest @@ -148,7 +148,7 @@ describe(`DiscordService`, (): void => { .mockReturnValue(discordActivitySoniaService); discordActivitySoniaServiceInitSpy = jest .spyOn(discordActivitySoniaService, `init`) - .mockResolvedValue(createMock()); + .mockResolvedValue(createHydratedMock()); discordSoniaEmotionalStateServiceGetInstanceSpy = jest .spyOn(DiscordSoniaEmotionalStateService, `getInstance`) .mockReturnValue(discordSoniaEmotionalStateService); diff --git a/src/features/discord/users/services/config/discord-sonia-config.service.spec.ts b/src/features/discord/users/services/config/discord-sonia-config.service.spec.ts index 0ffb1b695..a79891d8b 100644 --- a/src/features/discord/users/services/config/discord-sonia-config.service.spec.ts +++ b/src/features/discord/users/services/config/discord-sonia-config.service.spec.ts @@ -6,7 +6,7 @@ import { CoreEventService } from '../../../../core/services/core-event.service'; import { IDiscordSoniaConfig } from '../../../interfaces/discord-sonia-config'; import { IDiscordSoniaCorporationMessageEmbedAuthorConfig } from '../../../interfaces/discord-sonia-corporation-message-embed-author-config'; import { Guild } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`DiscordSoniaConfigService`, (): void => { let service: DiscordSoniaConfigService; @@ -193,7 +193,7 @@ describe(`DiscordSoniaConfigService`, (): void => { beforeEach((): void => { service = DiscordSoniaConfigService.getInstance(); - guild = createMock(); + guild = createHydratedMock(); discordSoniaConfigCoreService.devGuildIdWhitelist = [`dummy-guild-id`]; }); diff --git a/src/features/firebase/functions/guilds/channels/features/handle-firebase-guild-channel-feature-breaking-change.spec.ts b/src/features/firebase/functions/guilds/channels/features/handle-firebase-guild-channel-feature-breaking-change.spec.ts index 3685ea8db..179ee3850 100644 --- a/src/features/firebase/functions/guilds/channels/features/handle-firebase-guild-channel-feature-breaking-change.spec.ts +++ b/src/features/firebase/functions/guilds/channels/features/handle-firebase-guild-channel-feature-breaking-change.spec.ts @@ -5,7 +5,7 @@ import { IFirebaseGuildChannelFeatureNoonV1 } from '../../../../interfaces/guild import { IFirebaseGuildChannelFeatureReleaseNotesV1 } from '../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-release-notes-v1'; import { IFirebaseGuildChannelFeatureV1 } from '../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v1'; import { IFirebaseGuildChannelFeatureV2 } from '../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v2'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`handleFirebaseGuildChannelFeatureBreakingChange()`, (): void => { describe(`when the given Firebase guild channel has no version`, (): void => { @@ -28,7 +28,7 @@ describe(`handleFirebaseGuildChannelFeatureBreakingChange()`, (): void => { let firebaseGuildChannelFeature: IFirebaseGuildChannelFeatureV1; beforeEach((): void => { - firebaseGuildChannelFeature = createMock({ + firebaseGuildChannelFeature = createHydratedMock({ noon: undefined, version: FirebaseGuildChannelFeatureVersionEnum.V1, }); @@ -55,9 +55,9 @@ describe(`handleFirebaseGuildChannelFeatureBreakingChange()`, (): void => { let firebaseGuildChannelFeature: IFirebaseGuildChannelFeatureV2; beforeEach((): void => { - firebaseGuildChannelFeature = createMock({ - noon: createMock(), - releaseNotes: createMock(), + firebaseGuildChannelFeature = createHydratedMock({ + noon: createHydratedMock(), + releaseNotes: createHydratedMock(), version: FirebaseGuildChannelFeatureVersionEnum.V2, }); }); diff --git a/src/features/firebase/functions/guilds/channels/features/upgrade-firebase-guild-channel-feature-to-v2.spec.ts b/src/features/firebase/functions/guilds/channels/features/upgrade-firebase-guild-channel-feature-to-v2.spec.ts index 77f716b3b..ebc0d0670 100644 --- a/src/features/firebase/functions/guilds/channels/features/upgrade-firebase-guild-channel-feature-to-v2.spec.ts +++ b/src/features/firebase/functions/guilds/channels/features/upgrade-firebase-guild-channel-feature-to-v2.spec.ts @@ -1,13 +1,13 @@ import { upgradeFirebaseGuildChannelFeatureToV2 } from './upgrade-firebase-guild-channel-feature-to-v2'; import { FirebaseGuildChannelFeatureVersionEnum } from '../../../../enums/guilds/channels/features/firebase-guild-channel-feature-version.enum'; import { IFirebaseGuildChannelFeatureV1 } from '../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v1'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildChannelFeatureToV2()`, (): void => { let firebaseGuildChannelFeature: IFirebaseGuildChannelFeatureV1; beforeEach((): void => { - firebaseGuildChannelFeature = createMock(); + firebaseGuildChannelFeature = createHydratedMock(); }); it(`should return the same noon configuration`, (): void => { diff --git a/src/features/firebase/functions/guilds/channels/handle-firebase-guild-channel-breaking-change.spec.ts b/src/features/firebase/functions/guilds/channels/handle-firebase-guild-channel-breaking-change.spec.ts index 4ee96b6bb..cf1560b9d 100644 --- a/src/features/firebase/functions/guilds/channels/handle-firebase-guild-channel-breaking-change.spec.ts +++ b/src/features/firebase/functions/guilds/channels/handle-firebase-guild-channel-breaking-change.spec.ts @@ -7,7 +7,7 @@ import { IFirebaseGuildChannelFeatureV1 } from '../../../interfaces/guilds/chann import { IFirebaseGuildChannelFeatureV2 } from '../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v2'; import { IFirebaseGuildChannelV1 } from '../../../interfaces/guilds/channels/firebase-guild-channel-v1'; import { IFirebaseGuildChannelV2 } from '../../../interfaces/guilds/channels/firebase-guild-channel-v2'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`handleFirebaseGuildChannelBreakingChange()`, (): void => { describe(`when the given Firebase guild channel has no version`, (): void => { @@ -30,7 +30,7 @@ describe(`handleFirebaseGuildChannelBreakingChange()`, (): void => { let firebaseGuildChannel: IFirebaseGuildChannelV1; beforeEach((): void => { - firebaseGuildChannel = createMock({ + firebaseGuildChannel = createHydratedMock({ features: undefined, id: `dummy-id`, version: FirebaseGuildChannelVersionEnum.V1, @@ -53,7 +53,7 @@ describe(`handleFirebaseGuildChannelBreakingChange()`, (): void => { describe(`when there is some features configured`, (): void => { beforeEach((): void => { - firebaseGuildChannel.features = createMock({ + firebaseGuildChannel.features = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -99,8 +99,8 @@ describe(`handleFirebaseGuildChannelBreakingChange()`, (): void => { let firebaseGuildChannel: IFirebaseGuildChannelV2; beforeEach((): void => { - firebaseGuildChannel = createMock({ - features: createMock(), + firebaseGuildChannel = createHydratedMock({ + features: createHydratedMock(), id: `dummy-id`, version: FirebaseGuildChannelVersionEnum.V2, }); diff --git a/src/features/firebase/functions/guilds/channels/upgrade-firebase-guild-channel-to-v2.spec.ts b/src/features/firebase/functions/guilds/channels/upgrade-firebase-guild-channel-to-v2.spec.ts index ca873e74f..b36ece9a0 100644 --- a/src/features/firebase/functions/guilds/channels/upgrade-firebase-guild-channel-to-v2.spec.ts +++ b/src/features/firebase/functions/guilds/channels/upgrade-firebase-guild-channel-to-v2.spec.ts @@ -5,13 +5,17 @@ import { FirebaseGuildChannelVersionEnum } from '../../../enums/guilds/channels/ import { IFirebaseGuildChannelFeatureV1 } from '../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v1'; import { IFirebaseGuildChannelFeatureV2 } from '../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v2'; import { IFirebaseGuildChannelV1 } from '../../../interfaces/guilds/channels/firebase-guild-channel-v1'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildChannelToV2()`, (): void => { let firebaseGuildChannel: IFirebaseGuildChannelV1; beforeEach((): void => { - firebaseGuildChannel = createMock(); + firebaseGuildChannel = createHydratedMock({ + features: undefined, + id: `dummy-id`, + version: FirebaseGuildChannelVersionEnum.V1, + }); }); describe(`when there is no features configured`, (): void => { @@ -30,7 +34,7 @@ describe(`upgradeFirebaseGuildChannelToV2()`, (): void => { describe(`when there is some features configured`, (): void => { beforeEach((): void => { - firebaseGuildChannel.features = createMock({ + firebaseGuildChannel.features = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -60,7 +64,7 @@ describe(`upgradeFirebaseGuildChannelToV2()`, (): void => { const result = upgradeFirebaseGuildChannelToV2(firebaseGuildChannel); - expect(result.id).toStrictEqual(firebaseGuildChannel.id); + expect(result.id).toStrictEqual(`dummy-id`); }); it(`should return a v2 version`, (): void => { diff --git a/src/features/firebase/functions/guilds/checks/has-firebase-guild-channels.spec.ts b/src/features/firebase/functions/guilds/checks/has-firebase-guild-channels.spec.ts index c2fab9ccd..1c2f3c2bf 100644 --- a/src/features/firebase/functions/guilds/checks/has-firebase-guild-channels.spec.ts +++ b/src/features/firebase/functions/guilds/checks/has-firebase-guild-channels.spec.ts @@ -6,14 +6,14 @@ import { IFirebaseGuildV3 } from '../../../interfaces/guilds/firebase-guild-v3'; import { IFirebaseGuildV4 } from '../../../interfaces/guilds/firebase-guild-v4'; import { IFirebaseGuildV5 } from '../../../interfaces/guilds/firebase-guild-v5'; import { IFirebaseGuild } from '../../../types/guilds/firebase-guild'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`hasFirebaseGuildChannels()`, (): void => { let firebaseGuild: IFirebaseGuild; describe(`when the given Firebase guild is a v1`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); }); @@ -29,7 +29,7 @@ describe(`hasFirebaseGuildChannels()`, (): void => { describe(`when the given Firebase guild is a v2`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); }); @@ -45,7 +45,7 @@ describe(`hasFirebaseGuildChannels()`, (): void => { describe(`when the given Firebase guild is a v3`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V3, }); }); @@ -61,7 +61,7 @@ describe(`hasFirebaseGuildChannels()`, (): void => { describe(`when the given Firebase guild is a v4`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V4, }); }); @@ -77,7 +77,7 @@ describe(`hasFirebaseGuildChannels()`, (): void => { describe(`when the given Firebase guild is a v5`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); }); diff --git a/src/features/firebase/functions/guilds/checks/has-firebase-guild-last-release-notes-version.spec.ts b/src/features/firebase/functions/guilds/checks/has-firebase-guild-last-release-notes-version.spec.ts index 17ade54b2..45cd0ac0b 100644 --- a/src/features/firebase/functions/guilds/checks/has-firebase-guild-last-release-notes-version.spec.ts +++ b/src/features/firebase/functions/guilds/checks/has-firebase-guild-last-release-notes-version.spec.ts @@ -6,14 +6,14 @@ import { IFirebaseGuildV3 } from '../../../interfaces/guilds/firebase-guild-v3'; import { IFirebaseGuildV4 } from '../../../interfaces/guilds/firebase-guild-v4'; import { IFirebaseGuildV5 } from '../../../interfaces/guilds/firebase-guild-v5'; import { IFirebaseGuild } from '../../../types/guilds/firebase-guild'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`hasFirebaseGuildLastReleaseNotesVersion()`, (): void => { let firebaseGuild: IFirebaseGuild; describe(`when the given Firebase guild is a v1`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); }); @@ -29,7 +29,7 @@ describe(`hasFirebaseGuildLastReleaseNotesVersion()`, (): void => { describe(`when the given Firebase guild is a v2`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); }); @@ -45,7 +45,7 @@ describe(`hasFirebaseGuildLastReleaseNotesVersion()`, (): void => { describe(`when the given Firebase guild is a v3`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V3, }); }); @@ -61,7 +61,7 @@ describe(`hasFirebaseGuildLastReleaseNotesVersion()`, (): void => { describe(`when the given Firebase guild is a v4`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V4, }); }); @@ -77,7 +77,7 @@ describe(`hasFirebaseGuildLastReleaseNotesVersion()`, (): void => { describe(`when the given Firebase guild is a v5`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); }); diff --git a/src/features/firebase/functions/guilds/create-firebase-guild.spec.ts b/src/features/firebase/functions/guilds/create-firebase-guild.spec.ts index 1d9c86650..4970d4adf 100644 --- a/src/features/firebase/functions/guilds/create-firebase-guild.spec.ts +++ b/src/features/firebase/functions/guilds/create-firebase-guild.spec.ts @@ -1,12 +1,12 @@ import { createFirebaseGuild } from './create-firebase-guild'; import { ICreateFirebaseGuild } from '../../interfaces/guilds/create-firebase-guild'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`createFirebaseGuild()`, (): void => { let data: ICreateFirebaseGuild; beforeEach((): void => { - data = createMock({ + data = createHydratedMock({ id: `dummy-id`, }); }); diff --git a/src/features/firebase/functions/guilds/handle-firebase-guild-breaking-change.spec.ts b/src/features/firebase/functions/guilds/handle-firebase-guild-breaking-change.spec.ts index 76168fde3..91f8f73f0 100644 --- a/src/features/firebase/functions/guilds/handle-firebase-guild-breaking-change.spec.ts +++ b/src/features/firebase/functions/guilds/handle-firebase-guild-breaking-change.spec.ts @@ -11,7 +11,7 @@ import { IFirebaseGuildV2 } from '../../interfaces/guilds/firebase-guild-v2'; import { IFirebaseGuildV3 } from '../../interfaces/guilds/firebase-guild-v3'; import { IFirebaseGuildV4 } from '../../interfaces/guilds/firebase-guild-v4'; import { IFirebaseGuildV5 } from '../../interfaces/guilds/firebase-guild-v5'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`handleFirebaseGuildBreakingChange()`, (): void => { describe(`when the given Firebase guild has no version`, (): void => { @@ -34,7 +34,7 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { let firebaseGuild: IFirebaseGuildV1; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ id: `dummy-id`, version: FirebaseGuildVersionEnum.V1, }); @@ -69,7 +69,7 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { let firebaseGuild: IFirebaseGuildV2; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ id: `dummy-id`, lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V2, @@ -113,8 +113,8 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { let firebaseGuild: IFirebaseGuildV3; beforeEach((): void => { - firebaseGuild = createMock({ - channels: [createMock()], + firebaseGuild = createHydratedMock({ + channels: [createHydratedMock()], id: `dummy-id`, lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V3, @@ -158,8 +158,8 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { let firebaseGuild: IFirebaseGuildV4; beforeEach((): void => { - firebaseGuild = createMock({ - channels: {}, + firebaseGuild = createHydratedMock({ + channels: undefined, id: `dummy-id`, lastReleaseNotesVersion: `dummy-last-release-notes-version`, version: FirebaseGuildVersionEnum.V4, @@ -183,7 +183,7 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { describe(`when there is a channel configured`, (): void => { beforeEach((): void => { firebaseGuild.channels = { - 1: createMock({ + 1: createHydratedMock({ features: { noon: { isEnabled: false, @@ -248,7 +248,7 @@ describe(`handleFirebaseGuildBreakingChange()`, (): void => { let firebaseGuild: IFirebaseGuildV5; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); }); diff --git a/src/features/firebase/functions/guilds/is-up-to-date-firebase-guild.spec.ts b/src/features/firebase/functions/guilds/is-up-to-date-firebase-guild.spec.ts index a40f81894..dc93cfbc6 100644 --- a/src/features/firebase/functions/guilds/is-up-to-date-firebase-guild.spec.ts +++ b/src/features/firebase/functions/guilds/is-up-to-date-firebase-guild.spec.ts @@ -5,14 +5,14 @@ import { IFirebaseGuildV2 } from '../../interfaces/guilds/firebase-guild-v2'; import { IFirebaseGuildV3 } from '../../interfaces/guilds/firebase-guild-v3'; import { IFirebaseGuildV4 } from '../../interfaces/guilds/firebase-guild-v4'; import { IFirebaseGuildV5 } from '../../interfaces/guilds/firebase-guild-v5'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`isUpToDateFirebaseGuild()`, (): void => { describe(`when the given Firebase guild is a v1`, (): void => { let firebaseGuild: IFirebaseGuildV1; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); }); @@ -30,7 +30,7 @@ describe(`isUpToDateFirebaseGuild()`, (): void => { let firebaseGuild: IFirebaseGuildV2; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V2, }); }); @@ -48,7 +48,7 @@ describe(`isUpToDateFirebaseGuild()`, (): void => { let firebaseGuild: IFirebaseGuildV3; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V3, }); }); @@ -66,7 +66,7 @@ describe(`isUpToDateFirebaseGuild()`, (): void => { let firebaseGuild: IFirebaseGuildV4; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V4, }); }); @@ -84,7 +84,7 @@ describe(`isUpToDateFirebaseGuild()`, (): void => { let firebaseGuild: IFirebaseGuildV5; beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); }); diff --git a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v2.spec.ts b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v2.spec.ts index 769b718d6..37888fe5d 100644 --- a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v2.spec.ts +++ b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v2.spec.ts @@ -1,13 +1,13 @@ import { upgradeFirebaseGuildToV2 } from './upgrade-firebase-guild-to-v2'; import { FirebaseGuildVersionEnum } from '../../enums/guilds/firebase-guild-version.enum'; import { IFirebaseGuildV1 } from '../../interfaces/guilds/firebase-guild-v1'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildToV2()`, (): void => { let firebaseGuild: IFirebaseGuildV1; beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); it(`should return the same id`, (): void => { diff --git a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v3.spec.ts b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v3.spec.ts index fd0cb15b5..49791e8c2 100644 --- a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v3.spec.ts +++ b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v3.spec.ts @@ -1,13 +1,13 @@ import { upgradeFirebaseGuildToV3 } from './upgrade-firebase-guild-to-v3'; import { FirebaseGuildVersionEnum } from '../../enums/guilds/firebase-guild-version.enum'; import { IFirebaseGuildV2 } from '../../interfaces/guilds/firebase-guild-v2'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildToV3()`, (): void => { let firebaseGuild: IFirebaseGuildV2; beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); it(`should return an empty list of channels`, (): void => { diff --git a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v4.spec.ts b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v4.spec.ts index 2f10687ed..6b5b322f1 100644 --- a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v4.spec.ts +++ b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v4.spec.ts @@ -1,13 +1,13 @@ import { upgradeFirebaseGuildToV4 } from './upgrade-firebase-guild-to-v4'; import { FirebaseGuildVersionEnum } from '../../enums/guilds/firebase-guild-version.enum'; import { IFirebaseGuildV3 } from '../../interfaces/guilds/firebase-guild-v3'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildToV4()`, (): void => { let firebaseGuild: IFirebaseGuildV3; beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); it(`should return an empty map of channels`, (): void => { diff --git a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v5.spec.ts b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v5.spec.ts index e93e9c301..0704e5a46 100644 --- a/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v5.spec.ts +++ b/src/features/firebase/functions/guilds/upgrade-firebase-guild-to-v5.spec.ts @@ -6,13 +6,18 @@ import { FirebaseGuildVersionEnum } from '../../enums/guilds/firebase-guild-vers import { IFirebaseGuildChannelV1 } from '../../interfaces/guilds/channels/firebase-guild-channel-v1'; import { IFirebaseGuildChannelV2 } from '../../interfaces/guilds/channels/firebase-guild-channel-v2'; import { IFirebaseGuildV4 } from '../../interfaces/guilds/firebase-guild-v4'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`upgradeFirebaseGuildToV5()`, (): void => { let firebaseGuild: IFirebaseGuildV4; beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock({ + channels: undefined, + id: `dummy-id`, + lastReleaseNotesVersion: `dummy-last-release-notes-version`, + version: FirebaseGuildVersionEnum.V4, + }); }); describe(`when there is no channel`, (): void => { @@ -32,7 +37,7 @@ describe(`upgradeFirebaseGuildToV5()`, (): void => { describe(`when there is a channel configured`, (): void => { beforeEach((): void => { firebaseGuild.channels = { - 1: createMock({ + 1: createHydratedMock({ features: { noon: { isEnabled: false, @@ -73,7 +78,7 @@ describe(`upgradeFirebaseGuildToV5()`, (): void => { const result = upgradeFirebaseGuildToV5(firebaseGuild); - expect(result.id).toStrictEqual(firebaseGuild.id); + expect(result.id).toStrictEqual(`dummy-id`); }); it(`should return the same last release notes version`, (): void => { @@ -81,7 +86,7 @@ describe(`upgradeFirebaseGuildToV5()`, (): void => { const result = upgradeFirebaseGuildToV5(firebaseGuild); - expect(result.lastReleaseNotesVersion).toStrictEqual(firebaseGuild.lastReleaseNotesVersion); + expect(result.lastReleaseNotesVersion).toStrictEqual(`dummy-last-release-notes-version`); }); it(`should return a v5 version`, (): void => { diff --git a/src/features/firebase/services/__mocks__/firebase-app.service.ts b/src/features/firebase/services/__mocks__/firebase-app.service.ts index 672bf7d41..c6320b4fc 100644 --- a/src/features/firebase/services/__mocks__/firebase-app.service.ts +++ b/src/features/firebase/services/__mocks__/firebase-app.service.ts @@ -2,7 +2,7 @@ import { AbstractService } from '../../../../classes/services/abstract.service'; import { ServiceNameEnum } from '../../../../enums/service-name.enum'; import admin from 'firebase-admin'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; export class FirebaseAppService extends AbstractService { private static _instance: FirebaseAppService; @@ -23,6 +23,6 @@ export class FirebaseAppService extends AbstractService { public init(): void {} public getApp(): admin.app.App | undefined { - return createMock(); + return createHydratedMock(); } } diff --git a/src/features/firebase/services/firebase-app.service.spec.ts b/src/features/firebase/services/firebase-app.service.spec.ts index 5f837fc75..25ad17702 100644 --- a/src/features/firebase/services/firebase-app.service.spec.ts +++ b/src/features/firebase/services/firebase-app.service.spec.ts @@ -5,7 +5,7 @@ import { ILoggerLog } from '../../logger/interfaces/logger-log'; import { LoggerService } from '../../logger/services/logger.service'; import { FirebaseAppEnum } from '../enums/firebase-app.enum'; import * as admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../logger/services/chalk/chalk.service`); jest.mock(`firebase-admin`); @@ -66,7 +66,7 @@ describe(`FirebaseAppService`, (): void => { beforeEach((): void => { service = new FirebaseAppService(); - credential = createMock(); + credential = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); initializeAppSpy = jest.spyOn(admin, `initializeApp`).mockImplementation(); jest.spyOn(admin.credential, `applicationDefault`).mockReturnValue(credential); @@ -117,7 +117,7 @@ describe(`FirebaseAppService`, (): void => { beforeEach((): void => { service = new FirebaseAppService(); - app = createMock(); + app = createHydratedMock(); jest.spyOn(admin, `initializeApp`).mockReturnValue(app); }); diff --git a/src/features/firebase/services/firebase-update-core.service.spec.ts b/src/features/firebase/services/firebase-update-core.service.spec.ts index 1518bda4a..d5df10f6f 100644 --- a/src/features/firebase/services/firebase-update-core.service.spec.ts +++ b/src/features/firebase/services/firebase-update-core.service.spec.ts @@ -1,7 +1,7 @@ import { FirebaseUpdateCoreService } from './firebase-update-core.service'; import { ServiceNameEnum } from '../../../enums/service-name.enum'; import _ from 'lodash'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../logger/services/chalk/chalk.service`); @@ -57,7 +57,7 @@ describe(`FirebaseUpdateCoreService`, (): void => { describe(`when the given entity is a valid and not up-to-date`, (): void => { beforeEach((): void => { - entity = createMock({ + entity = createHydratedMock({ id: `id`, }); }); @@ -73,7 +73,7 @@ describe(`FirebaseUpdateCoreService`, (): void => { describe(`when the given entity is a valid and up-to-date`, (): void => { beforeEach((): void => { - entity = createMock({ + entity = createHydratedMock({ id: `dummy-id`, }); }); @@ -107,7 +107,7 @@ describe(`FirebaseUpdateCoreService`, (): void => { describe(`when the given entity is valid`, (): void => { beforeEach((): void => { - entity = createMock(); + entity = createHydratedMock(); }); it(`should return true`, (): void => { @@ -144,7 +144,7 @@ describe(`FirebaseUpdateCoreService`, (): void => { describe(`when the given IDummy is valid and not up-to-date`, (): void => { beforeEach((): void => { - entity = createMock({ + entity = createHydratedMock({ id: `id`, }); }); @@ -162,7 +162,7 @@ describe(`FirebaseUpdateCoreService`, (): void => { describe(`when the given IDummy is valid and up-to-date`, (): void => { beforeEach((): void => { - entity = createMock({ + entity = createHydratedMock({ id: `dummy-id`, }); }); diff --git a/src/features/firebase/services/firebase.service.spec.ts b/src/features/firebase/services/firebase.service.spec.ts index 8ffed5159..a8af54ad6 100644 --- a/src/features/firebase/services/firebase.service.spec.ts +++ b/src/features/firebase/services/firebase.service.spec.ts @@ -9,7 +9,7 @@ import { ILoggerLog } from '../../logger/interfaces/logger-log'; import { LoggerService } from '../../logger/services/logger.service'; import { FirebaseGuildsStoreService } from '../stores/guilds/services/firebase-guilds-store.service'; import * as admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../logger/services/chalk/chalk.service`); @@ -82,11 +82,11 @@ describe(`FirebaseService`, (): void => { beforeEach((): void => { service = new FirebaseService(); - firebaseAppService = createMock(); - firebaseGuildsService = createMock(); - firebaseGuildsNewVersionService = createMock(); - firebaseGuildsStoreService = createMock(); - firebaseGuildsBreakingChangeService = createMock(); + firebaseAppService = createHydratedMock(); + firebaseGuildsService = createHydratedMock(); + firebaseGuildsNewVersionService = createHydratedMock(); + firebaseGuildsStoreService = createHydratedMock(); + firebaseGuildsBreakingChangeService = createHydratedMock(); firebaseAppServiceGetInstanceSpy = jest .spyOn(FirebaseAppService, `getInstance`) @@ -258,7 +258,7 @@ describe(`FirebaseService`, (): void => { let writeResult: admin.firestore.WriteResult; beforeEach((): void => { - writeResult = createMock(); + writeResult = createHydratedMock(); firebaseGuildsBreakingChangeServiceGetInstanceInitSpy.mockResolvedValue(writeResult); }); diff --git a/src/features/firebase/services/guilds/channels/features/firebase-guilds-channels-features.service.spec.ts b/src/features/firebase/services/guilds/channels/features/firebase-guilds-channels-features.service.spec.ts index f835aaa6f..29127976e 100644 --- a/src/features/firebase/services/guilds/channels/features/firebase-guilds-channels-features.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/firebase-guilds-channels-features.service.spec.ts @@ -10,7 +10,7 @@ import { IFirebaseGuildChannelFeatureV1 } from '../../../../interfaces/guilds/ch import { IFirebaseGuildChannelFeatureV2 } from '../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-v2'; import { IFirebaseGuildChannelFeatureVFinal } from '../../../../types/guilds/channels/features/firebase-guild-channel-feature-v-final'; import { IFirebaseGuildChannelFeature } from '../../../../types/guilds/channels/features/firebase-guild-channel-feature'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../logger/services/chalk/chalk.service`); @@ -84,7 +84,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v1 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -104,7 +104,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v2 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -136,7 +136,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v1 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -156,7 +156,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v2 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -202,7 +202,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a feature`, (): void => { beforeEach((): void => { - feature = createMock(); + feature = createHydratedMock(); }); it(`should return true`, (): void => { @@ -254,7 +254,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v1`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -281,7 +281,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v2`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -329,7 +329,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v1 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, @@ -354,7 +354,7 @@ describe(`FirebaseGuildsChannelsFeaturesService`, (): void => { describe(`when the given feature is a v2 feature`, (): void => { beforeEach((): void => { - feature = createMock({ + feature = createHydratedMock({ noon: { isEnabled: false, version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, diff --git a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled-state.service.spec.ts b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled-state.service.spec.ts index c910cc1b1..4a14867d6 100644 --- a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled-state.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled-state.service.spec.ts @@ -8,7 +8,7 @@ import { FirebaseGuildChannelFeatureVersionEnum } from '../../../../../enums/gui import { FirebaseGuildChannelVersionEnum } from '../../../../../enums/guilds/channels/firebase-guild-channel-version.enum'; import { IFirebaseGuildChannel } from '../../../../../types/guilds/channels/firebase-guild-channel'; import { IFirebaseGuildVFinal } from '../../../../../types/guilds/firebase-guild-v-final'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -69,8 +69,8 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledStateService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsChannelsFeaturesNoonEnabledStateService(); - channel = createMock(); - firebaseGuild = createMock({ + channel = createHydratedMock(); + firebaseGuild = createHydratedMock({ id: `dummy-guild-id`, }); diff --git a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled.service.spec.ts b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled.service.spec.ts index 5c6a0622d..6558bbd1a 100644 --- a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon-enabled.service.spec.ts @@ -15,7 +15,7 @@ import { IFirebaseGuild } from '../../../../../types/guilds/firebase-guild'; import { FirebaseGuildsService } from '../../../firebase-guilds.service'; import { Guild } from 'discord.js'; import * as admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -128,7 +128,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the Firebase guilds collection is valid`, (): void => { beforeEach((): void => { - collectionReference = createMock>(); + collectionReference = createHydratedMock>(); firebaseGuildsServiceGetCollectionReferenceSpy.mockReturnValue(collectionReference); }); @@ -241,14 +241,14 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the Firebase guild is a Firebase guild`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); firebaseGuildsServiceGetGuildSpy.mockResolvedValue(firebaseGuild); }); describe(`when the Firebase guild is a Firebase guild not up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -280,7 +280,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the Firebase guild is a Firebase guild up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); @@ -322,7 +322,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the given Firebase guild is fully up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -373,12 +373,12 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the given Firebase guild is not fully up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); describe(`when the given Firebase guild does not have the channel with the given id`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'other-id': { id: `other-id`, @@ -431,7 +431,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the given Firebase guild does have a channel with the given id but without any features`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { id: `dummy-id`, @@ -488,7 +488,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the given Firebase guild does have a channel with the given id with features but without noon`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -548,7 +548,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the given Firebase guild does have a channel with the given id with noon feature`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -622,14 +622,14 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { id = `dummy-id`; channelId = `dummy-channel-id`; isEnabled = true; - firebaseGuild = createMock(); - updatedFirebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); + updatedFirebaseGuild = createHydratedMock(); updateMock = jest.fn().mockRejectedValue(new Error(`update error`)); docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); getUpdatedGuildSpy = jest.spyOn(service, `getUpdatedGuild`).mockReturnValue(updatedFirebaseGuild); @@ -675,7 +675,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); }); @@ -691,13 +691,13 @@ describe(`FirebaseGuildsChannelsFeaturesNoonEnabledService`, (): void => { describe(`when the Firebase guild was successfully updated`, (): void => { beforeEach((): void => { - writeResult = createMock(); + writeResult = createHydratedMock(); updateMock = jest.fn().mockResolvedValue(writeResult); docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); }); diff --git a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon.service.spec.ts b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon.service.spec.ts index 9386b5d15..06a565707 100644 --- a/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/noon/firebase-guilds-channels-features-noon.service.spec.ts @@ -5,7 +5,7 @@ import { FirebaseGuildChannelFeatureNoonVersionEnum } from '../../../../../enums import { IFirebaseGuildChannelFeatureNoonV1 } from '../../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-noon-v1'; import { IFirebaseGuildChannelFeatureNoonVFinal } from '../../../../../types/guilds/channels/features/firebase-guild-channel-feature-noon-v-final'; import { IFirebaseGuildChannelFeatureNoon } from '../../../../../types/guilds/channels/features/firebase-guild-channel-feature-noon'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -79,7 +79,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonService`, (): void => { describe(`when the given noon config is a v1 config`, (): void => { beforeEach((): void => { - noon = createMock({ + noon = createHydratedMock({ version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, }); }); @@ -103,7 +103,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonService`, (): void => { describe(`when the given noon config is a v1 config`, (): void => { beforeEach((): void => { - noon = createMock({ + noon = createHydratedMock({ version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, }); }); @@ -141,7 +141,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonService`, (): void => { describe(`when the given noon config is a valid config`, (): void => { beforeEach((): void => { - noon = createMock(); + noon = createHydratedMock(); }); it(`should return true`, (): void => { @@ -185,7 +185,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonService`, (): void => { describe(`when the given noon config is a v1`, (): void => { beforeEach((): void => { - noon = createMock({ + noon = createHydratedMock({ version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, }); }); @@ -224,7 +224,7 @@ describe(`FirebaseGuildsChannelsFeaturesNoonService`, (): void => { describe(`when the given noon config is a v1 noon config`, (): void => { beforeEach((): void => { - noon = createMock({ + noon = createHydratedMock({ version: FirebaseGuildChannelFeatureNoonVersionEnum.V1, }); }); diff --git a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled-state.service.spec.ts b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled-state.service.spec.ts index 85628a573..21c3849ed 100644 --- a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled-state.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled-state.service.spec.ts @@ -8,7 +8,7 @@ import { FirebaseGuildChannelFeatureVersionEnum } from '../../../../../enums/gui import { FirebaseGuildChannelVersionEnum } from '../../../../../enums/guilds/channels/firebase-guild-channel-version.enum'; import { IFirebaseGuildChannel } from '../../../../../types/guilds/channels/firebase-guild-channel'; import { IFirebaseGuildVFinal } from '../../../../../types/guilds/firebase-guild-v-final'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -69,8 +69,8 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledStateService`, (): vo beforeEach((): void => { service = new FirebaseGuildsChannelsFeaturesReleaseNotesEnabledStateService(); - channel = createMock(); - firebaseGuild = createMock({ + channel = createHydratedMock(); + firebaseGuild = createHydratedMock({ id: `dummy-guild-id`, }); diff --git a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled.service.spec.ts b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled.service.spec.ts index 4853f8de1..b1039fd15 100644 --- a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes-enabled.service.spec.ts @@ -15,7 +15,7 @@ import { IFirebaseGuild } from '../../../../../types/guilds/firebase-guild'; import { FirebaseGuildsService } from '../../../firebase-guilds.service'; import { Guild } from 'discord.js'; import * as admin from 'firebase-admin'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -128,7 +128,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the Firebase guilds collection is valid`, (): void => { beforeEach((): void => { - collectionReference = createMock>(); + collectionReference = createHydratedMock>(); firebaseGuildsServiceGetCollectionReferenceSpy.mockReturnValue(collectionReference); }); @@ -241,14 +241,14 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the Firebase guild is a Firebase guild`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); firebaseGuildsServiceGetGuildSpy.mockResolvedValue(firebaseGuild); }); describe(`when the Firebase guild is a Firebase guild not up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V1, }); @@ -280,7 +280,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the Firebase guild is a Firebase guild up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); @@ -322,7 +322,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the given Firebase guild is fully up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -373,12 +373,12 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the given Firebase guild is not fully up-to-date`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); describe(`when the given Firebase guild does not have the channel with the given id`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'other-id': { id: `other-id`, @@ -431,7 +431,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the given Firebase guild does have a channel with the given id but without any features`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { id: `dummy-id`, @@ -488,7 +488,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the given Firebase guild does have a channel with the given id with features but without release notes`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -548,7 +548,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the given Firebase guild does have a channel with the given id with release notes feature`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-id': { features: { @@ -622,14 +622,14 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => id = `dummy-id`; channelId = `dummy-channel-id`; isEnabled = true; - firebaseGuild = createMock(); - updatedFirebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); + updatedFirebaseGuild = createHydratedMock(); updateMock = jest.fn().mockRejectedValue(new Error(`update error`)); docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); getUpdatedGuildSpy = jest.spyOn(service, `getUpdatedGuild`).mockReturnValue(updatedFirebaseGuild); @@ -675,7 +675,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); }); @@ -691,13 +691,13 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesEnabledService`, (): void => describe(`when the Firebase guild was successfully updated`, (): void => { beforeEach((): void => { - writeResult = createMock(); + writeResult = createHydratedMock(); updateMock = jest.fn().mockResolvedValue(writeResult); docMock = jest.fn().mockReturnValue({ update: updateMock, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); }); diff --git a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes.service.spec.ts b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes.service.spec.ts index b938bf32c..a6effc370 100644 --- a/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/features/release-notes/firebase-guilds-channels-features-release-notes.service.spec.ts @@ -5,7 +5,7 @@ import { FirebaseGuildChannelFeatureReleaseNotesVersionEnum } from '../../../../ import { IFirebaseGuildChannelFeatureReleaseNotesV1 } from '../../../../../interfaces/guilds/channels/features/firebase-guild-channel-feature-release-notes-v1'; import { IFirebaseGuildChannelFeatureReleaseNotesVFinal } from '../../../../../types/guilds/channels/features/firebase-guild-channel-feature-release-notes-v-final'; import { IFirebaseGuildChannelFeatureReleaseNotes } from '../../../../../types/guilds/channels/features/firebase-guild-channel-feature-release-notes'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../../../logger/services/chalk/chalk.service`); @@ -79,7 +79,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesService`, (): void => { describe(`when the given release notes config is a v1 config`, (): void => { beforeEach((): void => { - releaseNotes = createMock({ + releaseNotes = createHydratedMock({ version: FirebaseGuildChannelFeatureReleaseNotesVersionEnum.V1, }); }); @@ -103,7 +103,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesService`, (): void => { describe(`when the given release notes config is a v1 config`, (): void => { beforeEach((): void => { - releaseNotes = createMock({ + releaseNotes = createHydratedMock({ version: FirebaseGuildChannelFeatureReleaseNotesVersionEnum.V1, }); }); @@ -141,7 +141,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesService`, (): void => { describe(`when the given release notes config is a valid config`, (): void => { beforeEach((): void => { - releaseNotes = createMock(); + releaseNotes = createHydratedMock(); }); it(`should return true`, (): void => { @@ -185,7 +185,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesService`, (): void => { describe(`when the given release notes config is a v1`, (): void => { beforeEach((): void => { - releaseNotes = createMock({ + releaseNotes = createHydratedMock({ version: FirebaseGuildChannelFeatureReleaseNotesVersionEnum.V1, }); }); @@ -224,7 +224,7 @@ describe(`FirebaseGuildsChannelsFeaturesReleaseNotesService`, (): void => { describe(`when the given release notes config is a v1 release notes config`, (): void => { beforeEach((): void => { - releaseNotes = createMock({ + releaseNotes = createHydratedMock({ version: FirebaseGuildChannelFeatureReleaseNotesVersionEnum.V1, }); }); diff --git a/src/features/firebase/services/guilds/channels/firebase-guilds-channels.service.spec.ts b/src/features/firebase/services/guilds/channels/firebase-guilds-channels.service.spec.ts index 5eb90521c..3ed26143f 100644 --- a/src/features/firebase/services/guilds/channels/firebase-guilds-channels.service.spec.ts +++ b/src/features/firebase/services/guilds/channels/firebase-guilds-channels.service.spec.ts @@ -10,7 +10,7 @@ import { IFirebaseGuildChannelV1 } from '../../../interfaces/guilds/channels/fir import { IFirebaseGuildChannelV2 } from '../../../interfaces/guilds/channels/firebase-guild-channel-v2'; import { IFirebaseGuildChannelVFinal } from '../../../types/guilds/channels/firebase-guild-channel-v-final'; import { IFirebaseGuildChannel } from '../../../types/guilds/channels/firebase-guild-channel'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../../logger/services/chalk/chalk.service`); @@ -84,7 +84,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v1 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: { noon: { isEnabled: false, @@ -108,7 +108,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v2 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: { noon: { isEnabled: false, @@ -144,7 +144,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v1 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ version: FirebaseGuildChannelVersionEnum.V1, }); }); @@ -160,7 +160,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v2 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: { noon: { isEnabled: false, @@ -210,7 +210,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a channel`, (): void => { beforeEach((): void => { - channel = createMock(); + channel = createHydratedMock(); }); it(`should return true`, (): void => { @@ -228,7 +228,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsChannelsService(); - channel = createMock({ + channel = createHydratedMock({ id: `dummy-id`, }); }); @@ -267,7 +267,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v1`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: { noon: { isEnabled: false, @@ -302,7 +302,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v2`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: { noon: { isEnabled: false, @@ -335,7 +335,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsChannelsService(); - createChannel = createMock({ + createChannel = createHydratedMock({ id: `dummy-id`, }); }); @@ -358,7 +358,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v1 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: undefined, id: `dummy-id`, version: FirebaseGuildChannelVersionEnum.V1, @@ -378,7 +378,7 @@ describe(`FirebaseGuildsChannelsService`, (): void => { describe(`when the given channel is a v2 channel`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ features: undefined, id: `dummy-id`, version: FirebaseGuildChannelVersionEnum.V2, diff --git a/src/features/firebase/services/guilds/firebase-guilds-breaking-change.service.spec.ts b/src/features/firebase/services/guilds/firebase-guilds-breaking-change.service.spec.ts index f6846b9de..ec2abb8b2 100644 --- a/src/features/firebase/services/guilds/firebase-guilds-breaking-change.service.spec.ts +++ b/src/features/firebase/services/guilds/firebase-guilds-breaking-change.service.spec.ts @@ -12,7 +12,7 @@ import { IFirebaseGuild } from '../../types/guilds/firebase-guild'; import * as admin from 'firebase-admin'; import { of, throwError } from 'rxjs'; import { take } from 'rxjs/operators'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -88,7 +88,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsBreakingChangeService(); - queryDocumentSnapshot = createMock>(); + queryDocumentSnapshot = createHydratedMock>(); forEachMock = jest .fn() .mockImplementation( @@ -96,13 +96,13 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); - writeResults = createMock(); + writeResults = createHydratedMock(); commitMock = jest.fn().mockResolvedValue(writeResults); updateMock = jest.fn().mockImplementation(); - writeBatch = createMock({ + writeBatch = createHydratedMock({ commit: commitMock, update: updateMock, }); @@ -304,7 +304,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { describe(`when there is no Firebase guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ exists: false, }); forEachMock = jest @@ -314,7 +314,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -340,9 +340,9 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { describe(`when there is a Firebase guild but on latest version`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuildVFinal => - createMock({ + createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }), exists: true, @@ -354,7 +354,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -392,9 +392,9 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { describe(`when there is two Firebase guilds but on latest version`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuildVFinal => - createMock({ + createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }), exists: true, @@ -407,7 +407,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -447,11 +447,11 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { let firebaseGuildV1: IFirebaseGuildV1; beforeEach((): void => { - firebaseGuildV1 = createMock({ + firebaseGuildV1 = createHydratedMock({ id: `dummy-id`, version: FirebaseGuildVersionEnum.V1, }); - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuildV1 => firebaseGuildV1, exists: true, }); @@ -462,7 +462,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -509,11 +509,11 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { let firebaseGuildV1: IFirebaseGuildV1; beforeEach((): void => { - firebaseGuildV1 = createMock({ + firebaseGuildV1 = createHydratedMock({ id: `dummy-id`, version: FirebaseGuildVersionEnum.V1, }); - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuildV1 => firebaseGuildV1, exists: true, }); @@ -525,7 +525,7 @@ describe(`FirebaseGuildsBreakingChangeService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); diff --git a/src/features/firebase/services/guilds/firebase-guilds-new-version-count-message-response.service.spec.ts b/src/features/firebase/services/guilds/firebase-guilds-new-version-count-message-response.service.spec.ts index 3936a320e..d3ac517fa 100644 --- a/src/features/firebase/services/guilds/firebase-guilds-new-version-count-message-response.service.spec.ts +++ b/src/features/firebase/services/guilds/firebase-guilds-new-version-count-message-response.service.spec.ts @@ -8,7 +8,7 @@ import { DiscordMessageCommandFeatureReleaseNotesConfigService } from '../../../ import { DiscordSoniaService } from '../../../discord/users/services/discord-sonia.service'; import { MessageEmbedAuthor } from 'discord.js'; import moment from 'moment-timezone'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -98,7 +98,7 @@ describe(`FirebaseGuildsNewVersionCountMessageResponseService`, (): void => { it(`should return a message response with an embed author`, (): void => { expect.assertions(1); - const messageEmbedAuthor: MessageEmbedAuthor = createMock(); + const messageEmbedAuthor: MessageEmbedAuthor = createHydratedMock(); discordSoniaServiceGetCorporationMessageEmbedAuthorSpy.mockReturnValue(messageEmbedAuthor); const result = service.getMessageResponse(totalGuildCount, guildCount, channelCount); diff --git a/src/features/firebase/services/guilds/firebase-guilds-new-version-count.service.spec.ts b/src/features/firebase/services/guilds/firebase-guilds-new-version-count.service.spec.ts index d117f58bd..8fba77e4e 100644 --- a/src/features/firebase/services/guilds/firebase-guilds-new-version-count.service.spec.ts +++ b/src/features/firebase/services/guilds/firebase-guilds-new-version-count.service.spec.ts @@ -8,7 +8,7 @@ import { IDiscordMessageResponse } from '../../../discord/messages/interfaces/di import { ILoggerLog } from '../../../logger/interfaces/logger-log'; import { LoggerService } from '../../../logger/services/logger.service'; import { Message } from 'discord.js'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); @@ -75,7 +75,7 @@ describe(`FirebaseGuildsNewVersionCountService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionCountService(); - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); discordGuildSoniaServiceSendMessageToChannelSpy = jest @@ -360,7 +360,7 @@ describe(`FirebaseGuildsNewVersionCountService`, (): void => { describe(`when the given guild messages is an array with one array of one message`, (): void => { beforeEach((): void => { - guildMessages = [[createMock()]]; + guildMessages = [[createHydratedMock()]]; }); it(`should log that one release note message was sent for one guild of one`, (): void => { @@ -399,7 +399,7 @@ describe(`FirebaseGuildsNewVersionCountService`, (): void => { describe(`when the given guild messages is an array with two arrays of one message`, (): void => { beforeEach((): void => { - guildMessages = [[createMock()], [createMock()]]; + guildMessages = [[createHydratedMock()], [createHydratedMock()]]; }); it(`should log that two release note messages were sent for two guilds of two`, (): void => { @@ -441,10 +441,10 @@ describe(`FirebaseGuildsNewVersionCountService`, (): void => { guildMessages = [ [], [null], - [createMock()], + [createHydratedMock()], [null, null], - [createMock(), null], - [createMock(), createMock()], + [createHydratedMock(), null], + [createHydratedMock(), createHydratedMock()], ]; }); diff --git a/src/features/firebase/services/guilds/firebase-guilds-new-version.service.spec.ts b/src/features/firebase/services/guilds/firebase-guilds-new-version.service.spec.ts index effb1da39..939b39ff6 100644 --- a/src/features/firebase/services/guilds/firebase-guilds-new-version.service.spec.ts +++ b/src/features/firebase/services/guilds/firebase-guilds-new-version.service.spec.ts @@ -36,7 +36,7 @@ import { Guild, GuildChannel, Message, TextChannel } from 'discord.js'; import * as admin from 'firebase-admin'; import { BehaviorSubject, of } from 'rxjs'; import { take } from 'rxjs/operators'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); jest.mock(`firebase-admin`); @@ -114,7 +114,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { sendNewReleaseNotesToEachGuild$Spy = jest .spyOn(service, `sendNewReleaseNotesToEachGuild$`) - .mockReturnValue(of(createMock())); + .mockReturnValue(of(createHydratedMock())); }); it(`should send a new release note to each known guild`, async (): Promise => { @@ -186,12 +186,12 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionService(); isReady$ = new BehaviorSubject<[true]>([true]); - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ id: `dummy-id`, lastReleaseNotesVersion: `1.0.0`, version: FirebaseGuildVersionEnum.V5, }); - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuild => firebaseGuild, }); forEachMock = jest @@ -201,12 +201,12 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); commitMock = jest.fn().mockRejectedValue(new Error(`Commit error`)); updateMock = jest.fn().mockImplementation(); - writeBatch = createMock({ + writeBatch = createHydratedMock({ commit: commitMock, update: updateMock, }); @@ -222,7 +222,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { appConfigServiceGetVersionSpy = jest.spyOn(appConfigService, `getVersion`).mockImplementation(); sendNewReleaseNotesFromFirebaseGuildSpy = jest .spyOn(service, `sendNewReleaseNotesFromFirebaseGuild`) - .mockResolvedValue(createMock()); + .mockResolvedValue(createHydratedMock()); }); it(`should wait that everything is ready`, async (): Promise => { @@ -446,7 +446,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when there is no Firebase guild`, (): void => { beforeEach((): void => { forEachMock = jest.fn().mockImplementation(); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -492,7 +492,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when there is one Firebase guild but it does not exists`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuild => firebaseGuild, exists: false, }); @@ -503,7 +503,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -549,11 +549,11 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when there is one Firebase guild on v1`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ id: `dummy-id`, version: FirebaseGuildVersionEnum.V1, }); - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuild => firebaseGuild, exists: true, }); @@ -564,7 +564,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -610,7 +610,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when there is one Firebase guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuild => firebaseGuild, exists: true, }); @@ -621,7 +621,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -731,7 +731,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the batch commit was successful`, (): void => { beforeEach((): void => { - commitMock.mockResolvedValue(createMock()); + commitMock.mockResolvedValue(createHydratedMock()); }); it(`should send the release notes message for the guild`, async (): Promise => { @@ -768,7 +768,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when there are two Firebase guilds`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: (): IFirebaseGuild => firebaseGuild, exists: true, }); @@ -780,7 +780,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); @@ -890,7 +890,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the batch commit was successful`, (): void => { beforeEach((): void => { - commitMock.mockResolvedValue(createMock()); + commitMock.mockResolvedValue(createHydratedMock()); }); it(`should send the release notes message for the guilds`, async (): Promise => { @@ -939,10 +939,10 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionService(); - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ version: FirebaseGuildVersionEnum.V5, }); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-id`, }); @@ -1102,10 +1102,10 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionService(); - channel = createMock(); - firebaseGuild = createMock(); + channel = createHydratedMock(); + firebaseGuild = createHydratedMock(); guildChannelsGetMock = jest.fn().mockImplementation(); - guild = createMock({ + guild = createHydratedMock({ channels: { cache: { get: guildChannelsGetMock, @@ -1125,7 +1125,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given Firebase guild channel id is undefined`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ id: undefined, }); }); @@ -1147,7 +1147,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given Firebase guild channel id is valid`, (): void => { beforeEach((): void => { - channel = createMock({ + channel = createHydratedMock({ id: `dummy-channel-id`, }); }); @@ -1155,7 +1155,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given Firebase guild has a valid release notes feature`, (): void => { describe(`when the given Firebase guild has a valid release note feature disabled`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-channel-id': { features: { @@ -1191,7 +1191,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given Firebase guild has a valid release notes feature enabled`, (): void => { beforeEach((): void => { - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-channel-id': { features: { @@ -1259,7 +1259,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { let guildChannel: GuildChannel; beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, }); @@ -1309,7 +1309,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMessageResponseSpy.mockResolvedValue(message); }); @@ -1340,10 +1340,10 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionService(); - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, }); - discordMessageResponse = createMock(); + discordMessageResponse = createHydratedMock(); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); loggerServiceErrorSpy = jest.spyOn(loggerService, `error`).mockImplementation(); @@ -1358,7 +1358,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given guild channel is not writable`, (): void => { beforeEach((): void => { - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, isText(): false { return false; @@ -1386,7 +1386,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { sendMock = jest.fn().mockRejectedValue(new Error(`send error`)); - guildChannel = createMock({ + guildChannel = createHydratedMock({ id: `dummy-guild-channel-id`, isText(): true { return true; @@ -1421,15 +1421,17 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { }); describe(`when the message response was successfully fetched`, (): void => { + let messageResponse: IDiscordMessageResponse; + beforeEach((): void => { - getMessageResponseSpy.mockResolvedValue( - createMock({ - options: { - split: false, - }, - response: `dummy-response`, - }) - ); + messageResponse = createHydratedMock({ + options: { + split: false, + }, + response: `dummy-response`, + }); + + getMessageResponseSpy.mockResolvedValue(messageResponse); }); it(`should log about sending a release notes message`, async (): Promise => { @@ -1450,9 +1452,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { await expect(service.sendMessageResponse(guildChannel)).rejects.toThrow(new Error(`send error`)); expect(sendMock).toHaveBeenCalledTimes(1); - expect(sendMock).toHaveBeenCalledWith(`dummy-response`, { - split: false, - }); + expect(sendMock).toHaveBeenCalledWith(`dummy-response`, messageResponse.options); }); describe(`when the sending of the message failed`, (): void => { @@ -1510,7 +1510,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMock.mockResolvedValue(message); }); @@ -1618,7 +1618,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the message response was successfully fetched`, (): void => { beforeEach((): void => { discordMessageCommandReleaseNotesServiceGetMessageResponseSpy.mockResolvedValue( - createMock({ + createHydratedMock({ options: { split: false, }, @@ -1752,7 +1752,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsNewVersionService(); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-guild-id`, }); @@ -1815,7 +1815,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the Firebase guild was successfully fetched`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); firebaseGuildsServiceGetGuildSpy.mockResolvedValue(firebaseGuild); }); @@ -1916,13 +1916,13 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { let channel2: IFirebaseGuildChannelVFinal; beforeEach((): void => { - channel1 = createMock({ + channel1 = createHydratedMock({ id: `dummy-channel-id-1`, }); - channel2 = createMock({ + channel2 = createHydratedMock({ id: `dummy-channel-id-2`, }); - firebaseGuild = createMock({ + firebaseGuild = createHydratedMock({ channels: { 'dummy-channel-id-1': channel1, 'dummy-channel-id-2': channel2, @@ -1992,7 +1992,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { let message: Message; beforeEach((): void => { - message = createMock(); + message = createHydratedMock(); sendMessageByChannelSpy.mockResolvedValue(message); }); @@ -2053,7 +2053,7 @@ describe(`FirebaseGuildsNewVersionService`, (): void => { describe(`when the given Firebase guild is valid`, (): void => { beforeEach((): void => { - firebaseGuild = createMock(); + firebaseGuild = createHydratedMock(); }); it(`should check if the guild is up-to-date`, (): void => { diff --git a/src/features/firebase/services/guilds/firebase-guilds-new-version.service.ts b/src/features/firebase/services/guilds/firebase-guilds-new-version.service.ts index 879228371..9c4f55531 100644 --- a/src/features/firebase/services/guilds/firebase-guilds-new-version.service.ts +++ b/src/features/firebase/services/guilds/firebase-guilds-new-version.service.ts @@ -232,7 +232,7 @@ export class FirebaseGuildsNewVersionService extends AbstractService { return Promise.all( _.map( - firebaseGuild.channels, + _.compact(_.values(firebaseGuild.channels)), (channel: Readonly): Promise => this.sendMessageByChannel(channel, firebaseGuild, guild) .then( diff --git a/src/features/firebase/services/guilds/firebase-guilds.service.spec.ts b/src/features/firebase/services/guilds/firebase-guilds.service.spec.ts index 22f06aee2..5802174b7 100644 --- a/src/features/firebase/services/guilds/firebase-guilds.service.spec.ts +++ b/src/features/firebase/services/guilds/firebase-guilds.service.spec.ts @@ -11,13 +11,13 @@ import { FirebaseAppService } from '../firebase-app.service'; import { Guild, Snowflake } from 'discord.js'; import * as admin from 'firebase-admin'; import { take } from 'rxjs/operators'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; jest.mock(`../../../logger/services/chalk/chalk.service`); jest.mock(`firebase-admin`, (): unknown => { return { credential: {}, - firestore: jest.fn().mockReturnValue(createMock()), + firestore: jest.fn().mockReturnValue(createHydratedMock()), }; }); @@ -85,7 +85,7 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - app = createMock(); + app = createHydratedMock(); settingsMock = jest.fn(); discordClientServiceIsReadySpy = jest.spyOn(discordClientService, `isReady`).mockResolvedValue(true); @@ -93,7 +93,7 @@ describe(`FirebaseGuildsService`, (): void => { getGuildsCountSpy = jest.spyOn(service, `getGuildsCount`).mockResolvedValue(8); loggerServiceDebugSpy = jest.spyOn(loggerService, `debug`).mockImplementation(); firestoreSpy = jest.spyOn(admin, `firestore`).mockReturnValue( - createMock({ + createHydratedMock({ settings: settingsMock, }) ); @@ -269,11 +269,11 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - collectionReference = createMock>(); + collectionReference = createHydratedMock>(); collectionMock = jest .fn, string[]>() .mockReturnValue(collectionReference); - firestore = createMock({ + firestore = createHydratedMock({ collection: collectionMock, }); @@ -354,8 +354,8 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - querySnapshot = createMock>(); - collectionReference = createMock>({ + querySnapshot = createHydratedMock>(); + collectionReference = createHydratedMock>({ get: (): Promise> => Promise.resolve(querySnapshot), }); @@ -406,10 +406,10 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ size: 8, }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ get: (): Promise> => Promise.resolve(querySnapshot), }); @@ -466,17 +466,17 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); guildId = `dummy-guild-id`; - documentSnapshot = createMock>(); + documentSnapshot = createHydratedMock>(); getMock = jest .fn>, IFirebaseGuild[]>() .mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock = jest .fn, string[]>() .mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -534,11 +534,11 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the fetch of the guild failed`, (): void => { beforeEach((): void => { getMock.mockRejectedValue(new Error(`error`)); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -568,13 +568,13 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the fetch of the guild was successful`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>(); + documentSnapshot = createHydratedMock>(); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -583,15 +583,15 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild does not exists`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>({ + documentSnapshot = createHydratedMock>({ exists: false, }); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -609,15 +609,15 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild exists`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>({ + documentSnapshot = createHydratedMock>({ exists: true, }); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -651,19 +651,19 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); guildId = `dummy-guild-id`; - documentSnapshot = createMock>(); - firebaseGuild = createMock(); + documentSnapshot = createHydratedMock>(); + firebaseGuild = createHydratedMock(); getMock = jest .fn>, IFirebaseGuild[]>() .mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock = jest .fn, string[]>() .mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -721,11 +721,11 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the fetch of the guild failed`, (): void => { beforeEach((): void => { getMock.mockRejectedValue(new Error(`error`)); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -755,13 +755,13 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the fetch of the guild was successful`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>(); + documentSnapshot = createHydratedMock>(); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -770,15 +770,15 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild does not exists`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>({ + documentSnapshot = createHydratedMock>({ exists: false, }); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -796,18 +796,18 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild exists`, (): void => { beforeEach((): void => { - documentSnapshot = createMock>({ + documentSnapshot = createHydratedMock>({ data(): IFirebaseGuild { return firebaseGuild; }, exists: true, }); getMock.mockResolvedValue(documentSnapshot); - documentReference = createMock>({ + documentReference = createHydratedMock>({ get: getMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -840,18 +840,18 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - guild = createMock({ + guild = createHydratedMock({ id: `dummy-id`, }); - writeResult = createMock(); + writeResult = createHydratedMock(); setMock = jest.fn, [IFirebaseGuildVFinal]>().mockResolvedValue(writeResult); - documentReference = createMock>({ + documentReference = createHydratedMock>({ set: setMock, }); docMock = jest .fn, string[]>() .mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -924,11 +924,11 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild was not successfully added into Firebase`, (): void => { beforeEach((): void => { setMock.mockRejectedValue(new Error(`error`)); - documentReference = createMock>({ + documentReference = createHydratedMock>({ set: setMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -944,13 +944,13 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when the guild was successfully added into Firebase`, (): void => { beforeEach((): void => { - writeResult = createMock(); + writeResult = createHydratedMock(); setMock.mockResolvedValue(writeResult); - documentReference = createMock>({ + documentReference = createHydratedMock>({ set: setMock, }); docMock.mockReturnValue(documentReference); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ doc: docMock, }); @@ -1039,7 +1039,7 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - firebaseGuilds = createMock(); + firebaseGuilds = createHydratedMock(); }); it(`should be an empty array by default`, async (): Promise => { @@ -1067,7 +1067,7 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - firebaseGuilds = createMock(); + firebaseGuilds = createHydratedMock(); }); it(`should notify that the Firebase guilds changed`, async (): Promise => { @@ -1088,9 +1088,9 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - writeBatch = createMock(); + writeBatch = createHydratedMock(); batchMock = jest.fn().mockReturnValue(writeBatch); - firestore = createMock({ + firestore = createHydratedMock({ batch: batchMock, }); @@ -1156,8 +1156,8 @@ describe(`FirebaseGuildsService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsService(); - firebaseGuild = createMock(); - queryDocumentSnapshot = createMock>({ + firebaseGuild = createHydratedMock(); + queryDocumentSnapshot = createHydratedMock>({ data: jest.fn().mockReturnValue(firebaseGuild), exists: true, }); @@ -1168,7 +1168,7 @@ describe(`FirebaseGuildsService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); onSnapshotMock = jest @@ -1176,7 +1176,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1249,7 +1249,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((_callback: () => void, onError: (error: Error) => void): void => { onError(new Error(`error`)); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1296,7 +1296,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1305,7 +1305,7 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when Firebase has one valid guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: jest.fn().mockReturnValue(firebaseGuild), exists: true, }); @@ -1316,7 +1316,7 @@ describe(`FirebaseGuildsService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); onSnapshotMock = jest @@ -1324,7 +1324,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1343,7 +1343,7 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when Firebase has one invalid guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: jest.fn().mockReturnValue(firebaseGuild), exists: false, }); @@ -1354,7 +1354,7 @@ describe(`FirebaseGuildsService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); onSnapshotMock = jest @@ -1362,7 +1362,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1381,7 +1381,7 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when Firebase has multiple valid guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: jest.fn().mockReturnValue(firebaseGuild), exists: true, }); @@ -1394,7 +1394,7 @@ describe(`FirebaseGuildsService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); onSnapshotMock = jest @@ -1402,7 +1402,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); @@ -1425,7 +1425,7 @@ describe(`FirebaseGuildsService`, (): void => { describe(`when Firebase has multiple invalid guild`, (): void => { beforeEach((): void => { - queryDocumentSnapshot = createMock>({ + queryDocumentSnapshot = createHydratedMock>({ data: jest.fn().mockReturnValue(firebaseGuild), exists: false, }); @@ -1438,7 +1438,7 @@ describe(`FirebaseGuildsService`, (): void => { callback(queryDocumentSnapshot); } ); - querySnapshot = createMock>({ + querySnapshot = createHydratedMock>({ forEach: forEachMock, }); onSnapshotMock = jest @@ -1446,7 +1446,7 @@ describe(`FirebaseGuildsService`, (): void => { .mockImplementation((onNext: (snapshot: admin.firestore.QuerySnapshot) => void): void => { onNext(querySnapshot); }); - collectionReference = createMock>({ + collectionReference = createHydratedMock>({ onSnapshot: onSnapshotMock, }); diff --git a/src/features/firebase/stores/guilds/services/firebase-guilds-store.service.spec.ts b/src/features/firebase/stores/guilds/services/firebase-guilds-store.service.spec.ts index 01e9d8873..ca5bf90ff 100644 --- a/src/features/firebase/stores/guilds/services/firebase-guilds-store.service.spec.ts +++ b/src/features/firebase/stores/guilds/services/firebase-guilds-store.service.spec.ts @@ -5,7 +5,7 @@ import { FirebaseGuildsService } from '../../../services/guilds/firebase-guilds. import { IFirebaseGuild } from '../../../types/guilds/firebase-guild'; import { FirebaseGuildsStore } from '../firebase-guilds-store'; import { Subject } from 'rxjs'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`FirebaseGuildsStoreService`, (): void => { let service: FirebaseGuildsStoreService; @@ -70,7 +70,7 @@ describe(`FirebaseGuildsStoreService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsStoreService(); onGuildsChange$ = new Subject(); - firebaseGuilds = createMock(); + firebaseGuilds = createHydratedMock(); firebaseGuildsServiceOnGuildsChange$Spy = jest .spyOn(firebaseGuildsService, `onGuildsChange$`) @@ -169,7 +169,7 @@ describe(`FirebaseGuildsStoreService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsStoreService(); - firebaseGuilds = createMock(); + firebaseGuilds = createHydratedMock(); firebaseGuildsStoreUpsertManySpy = jest.spyOn(firebaseGuildsStore, `upsertMany`).mockImplementation(); }); @@ -191,7 +191,7 @@ describe(`FirebaseGuildsStoreService`, (): void => { beforeEach((): void => { service = new FirebaseGuildsStoreService(); - firebaseGuilds = createMock(); + firebaseGuilds = createHydratedMock(); firebaseGuildsStoreAddSpy = jest.spyOn(firebaseGuildsStore, `add`).mockImplementation(); }); diff --git a/src/index.spec.ts b/src/index.spec.ts index ba9c83d14..74d7b6e6b 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,6 +1,6 @@ import { CoreService } from './features/core/services/core.service'; import { InitService } from './features/init/services/init.service'; -import { createMock } from 'ts-auto-mock'; +import { createHydratedMock } from 'ts-auto-mock'; describe(`Index`, (): void => { let coreServiceInitMock: jest.Mock; @@ -14,12 +14,12 @@ describe(`Index`, (): void => { initServiceInitMock = jest.fn(); coreServiceGetInstanceSy = jest.spyOn(CoreService, `getInstance`).mockReturnValue( - createMock({ + createHydratedMock({ init: coreServiceInitMock, }) ); initServiceGetInstanceSy = jest.spyOn(InitService, `getInstance`).mockReturnValue( - createMock({ + createHydratedMock({ init: initServiceInitMock, }) );