alina sireneva
b5bf02fc72
breaking: - `getChat`, `getFullChat` now only work for chats (channels/supergroups/basic groups) - for users, use `getUser` and `getFullUser` - many fields that previously had type `Chat` now have type `User | Chat`
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { after, before, describe, it } from 'node:test'
|
|
import { expect } from 'chai'
|
|
import { TelegramClient } from 'mtcute'
|
|
|
|
import { getApiParams } from './_utils.js'
|
|
|
|
describe('2. calling methods', () => {
|
|
const tg = new TelegramClient(getApiParams('dc2.session'))
|
|
|
|
before(() => tg.connect())
|
|
after(() => tg.close())
|
|
|
|
it('getUsers(@BotFather)', async () => {
|
|
const [user] = await tg.getUsers('botfather')
|
|
|
|
expect(user?.isBot).to.eq(true)
|
|
expect(user?.displayName).to.equal('BotFather')
|
|
})
|
|
|
|
it('getUsers(@BotFather) - cached', async () => {
|
|
const [user] = await tg.getUsers('botfather')
|
|
|
|
expect(user?.isBot).to.eq(true)
|
|
expect(user?.displayName).to.equal('BotFather')
|
|
})
|
|
|
|
it('getHistory(777000)', async () => {
|
|
await tg.findDialogs(777000) // ensure it's cached
|
|
|
|
const history = await tg.getHistory(777000, { limit: 5 })
|
|
|
|
expect(history[0].chat.type).to.equal('user')
|
|
expect(history[0].chat.id).to.equal(777000)
|
|
expect(history[0].chat.displayName).to.equal('Telegram')
|
|
})
|
|
})
|