Skip to content

Commit 333ed74

Browse files
committed
reformat tests
1 parent da5c1ae commit 333ed74

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

packages/main/test/telegram_bot.spec.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@ import { describe, it, expect } from 'vitest';
22
import TelegramBot from '../src/telegram_bot';
33

44
describe('telegram bot', () => {
5-
it('inline response', async () => {
6-
const bot = new TelegramBot('123456789').on(':message', async () => {
7-
return new Response('ok');
8-
});
9-
const request = new Request('http://example.com/123456789', {
10-
method: 'POST',
11-
body: JSON.stringify({ inline_query: { query: 'hello' } }),
12-
});
13-
expect(await (await bot.handle(request)).text()).toBe('ok');
14-
expect(bot.currentContext.update_type).toBe('inline');
15-
});
16-
it('message response', async () => {
17-
const bot = new TelegramBot('123456789').on(':message', async () => {
18-
return new Response('ok');
19-
});
20-
const request = new Request('http://example.com/123456789', {
21-
method: 'POST',
22-
body: JSON.stringify({ message: { text: 'hello' } }),
23-
});
24-
expect(await (await bot.handle(request)).text()).toBe('ok');
25-
expect(bot.currentContext.update_type).toBe('message');
26-
});
5+
// Test for inline query handling
6+
it('inline response', async () => {
7+
const bot = new TelegramBot('123456789').on(':message', async () => {
8+
return Promise.resolve(new Response('ok'));
9+
});
10+
const request = new Request('http://example.com/123456789', {
11+
method: 'POST',
12+
body: JSON.stringify({ inline_query: { query: 'hello' } }),
13+
});
14+
expect(await (await bot.handle(request)).text()).toBe('ok');
15+
expect(bot.currentContext.update_type).toBe('inline');
16+
});
17+
18+
// Test for message handling
19+
it('message response', async () => {
20+
const bot = new TelegramBot('123456789').on(':message', async () => {
21+
return Promise.resolve(new Response('ok'));
22+
});
23+
const request = new Request('http://example.com/123456789', {
24+
method: 'POST',
25+
body: JSON.stringify({ message: { text: 'hello' } }),
26+
});
27+
expect(await (await bot.handle(request)).text()).toBe('ok');
28+
expect(bot.currentContext.update_type).toBe('message');
29+
});
2730
});

0 commit comments

Comments
 (0)