Skip to content

Commit

Permalink
fix(noon): the disabled flag will works as expected
Browse files Browse the repository at this point in the history
before this fix it was working as an enabled flag
  • Loading branch information
C0ZEN committed Oct 31, 2020
1 parent 5ed27be commit cfc68f9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1427,26 +1427,60 @@ describe(`DiscordMessageCommandFeatureNoonDisabled`, (): void => {
firebaseGuild.id = `dummy-id`;
});

it(`should update the disable state for the feature command in the Firebase guilds`, async (): Promise<
void
> => {
expect.assertions(3);
describe(`when the new state is not disabled`, (): void => {
beforeEach((): void => {
shouldDisable = false;
});

await expect(
service.updateDatabase(
shouldDisable,
isDisabled,
firebaseGuild,
channel
)
).rejects.toThrow(new Error(`updateState error`));
it(`should update the enable state to enabled for the feature command in the Firebase guilds`, async (): Promise<
void
> => {
expect.assertions(3);

expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledTimes(1);
expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledWith(`dummy-id`, `dummy-channel-id`, false);
await expect(
service.updateDatabase(
shouldDisable,
isDisabled,
firebaseGuild,
channel
)
).rejects.toThrow(new Error(`updateState error`));

expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledTimes(1);
expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledWith(`dummy-id`, `dummy-channel-id`, true);
});
});

describe(`when the new state is disabled`, (): void => {
beforeEach((): void => {
shouldDisable = true;
});

it(`should update the enable state to not enabled for the feature command in the Firebase guilds`, async (): Promise<
void
> => {
expect.assertions(3);

await expect(
service.updateDatabase(
shouldDisable,
isDisabled,
firebaseGuild,
channel
)
).rejects.toThrow(new Error(`updateState error`));

expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledTimes(1);
expect(
firebaseGuildsChannelsFeaturesNoonEnabledServiceUpdateStateByGuildIdSpy
).toHaveBeenCalledWith(`dummy-id`, `dummy-channel-id`, false);
});
});

describe(`when the disable state for the feature command in the Firebase guilds was not successfully updated`, (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class DiscordMessageCommandFeatureNoonDisabled
): Promise<IDiscordCommandFlagSuccess> {
if (!_.isNil(id)) {
return FirebaseGuildsChannelsFeaturesNoonEnabledService.getInstance()
.updateStateByGuildId(id, discordChannel.id, shouldDisable)
.updateStateByGuildId(id, discordChannel.id, !shouldDisable)
.then(
(): Promise<IDiscordCommandFlagSuccess> =>
Promise.resolve(
Expand Down

0 comments on commit cfc68f9

Please sign in to comment.