Skip to content

Commit

Permalink
fix(tests): update reply use-case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
havrydotdev committed Oct 19, 2023
1 parent ffe1417 commit 8b43582
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/controllers/register.wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class RegisterWizard {
private readonly gameUseCases: GameUseCases,
) {
this.gameUseCases.findAll().then((games: Game[]) => {
console.log(games);
this.games = games;
});
}
Expand Down
18 changes: 15 additions & 3 deletions src/use-cases/reply/tests/reply.use-case.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,29 @@ describe('ReplyUseCases', () => {
it('should send send_picture message', async () => {
const replySpy = jest.spyOn(service, 'reply');
await useCases.sendPicture(ctx);
expect(replySpy).toHaveBeenCalledWith(ctx, 'messages.send_picture');
expect(replySpy).toHaveBeenCalledWith(ctx, 'messages.send_picture', {
reply_markup: Markup.removeKeyboard().reply_markup,
});
});
});

describe('sendGames', () => {
jest.useFakeTimers();

it('should send send_games message', async () => {
const games = [];

const reply_markup = Markup.keyboard(
games.map((game) => Markup.button.callback(game.title, game.title)),
).reply_markup;

reply_markup.resize_keyboard = true;

const replySpy = jest.spyOn(service, 'reply');
await useCases.sendGames(ctx);
expect(replySpy).toHaveBeenCalledWith(ctx, 'messages.send_games');
await useCases.sendGames(ctx, games);
expect(replySpy).toHaveBeenCalledWith(ctx, 'messages.send_games', {
reply_markup,
});
});
});

Expand Down

0 comments on commit 8b43582

Please sign in to comment.