Skip to content

Commit

Permalink
GH-442: Do not remove reactions if not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Mar 1, 2023
1 parent 357deb5 commit 0ec165e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/__tests__/GameBoard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ describe('GameBoard', () => {
await gameBoard.attemptNextTurn();
expect(tunnel.end).toHaveBeenCalledTimes(1);
});

it.each`
gameBoardReactions | calledTimes | description
${false} | ${0} | ${'not delete'}
${true} | ${1} | ${'delete'}
`(
'should $description reactions at the end of the game if reactions are $gameBoardReactions',
async ({ gameBoardReactions, calledTimes }) => {
configuration.gameBoardReactions = gameBoardReactions;
const reply = { reactions: { removeAll: jest.fn() } as any } as Message;
Object.assign(tunnel, { reply });
jest.spyOn(ai, 'operate').mockReturnValue({ move: 5, score: 1 });
await gameBoard.attemptNextTurn();
expect(reply.reactions.removeAll).toHaveBeenCalledTimes(calledTimes);
}
);
});

describe('Human: wait for a reaction', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/bot/entity/GameBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ export default class GameBoard {
const options = this.createBuilder().withEndingMessage(winner).toMessageOptions();
await this.tunnel.end(options);
} else {
await this.tunnel.reply?.reactions?.removeAll();
if (this.configuration.gameBoardReactions) {
await this.tunnel.reply?.reactions?.removeAll();
}
await this.update(interaction);
}

Expand Down

0 comments on commit 0ec165e

Please sign in to comment.