diff --git a/.snyk b/.snyk deleted file mode 100644 index ac8127c..0000000 --- a/.snyk +++ /dev/null @@ -1,8 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.13.3 -ignore: {} -# patches apply the minimum changes required to fix a vulnerability -patch: - SNYK-JS-AXIOS-174505: - - axios: - patched: '2019-05-06T02:59:41.072Z' diff --git a/README.md b/README.md index 3da3162..f84aa41 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,32 @@ -# Telegraf Test [![Codacy Badge](https://api.codacy.com/project/badge/Grade/626063315da84c0fa65f020a864774c4)](https://www.codacy.com/app/tiagodanin/Telegraf-Test?utm_source=github.com&utm_medium=referral&utm_content=TiagoDanin/Telegraf-Test&utm_campaign=Badge_Grade) [![Build Status](https://travis-ci.org/TiagoDanin/Telegraf-Test.svg?branch=master)](https://travis-ci.org/TiagoDanin/Telegraf-Test) [![Known Vulnerabilities](https://snyk.io/test/github/TiagoDanin/Telegraf-Test/badge.svg?targetFile=package.json)](https://snyk.io/test/github/TiagoDanin/Telegraf-Test?targetFile=package.json) +# Telegraf Test + +[![Travis](https://img.shields.io/travis/TiagoDanin/Telegraf-Test.svg?branch=master&style=flat-square)](https://travis-ci.org/TiagoDanin/Telegraf-Test) [![Downloads](https://img.shields.io/npm/dt/telegraf-test.svg?style=flat-square)](https://npmjs.org/package/telegraf-test) [![Node](https://img.shields.io/node/v/telegraf-test.svg?style=flat-square)](https://npmjs.org/package/telegraf-test) [![Version](https://img.shields.io/npm/v/telegraf-test.svg?style=flat-square)](https://npmjs.org/package/telegraf-test) [![XO code style](https://img.shields.io/badge/code%20style-XO-red.svg?style=flat-square)](https://github.com/xojs/xo) Telegraf Test - Simple Test ToolKit of Telegram Bots ## Features - Telegram bot api server emulator. -- Compatible with [Telegraf](http://telegraf.js.org) <3. -- Compatible with test framework. +- Compatible with Telegraf <3. +- Compatible with Mocha e others test framework. - Send message, inline query and callback query. - Work in local network. +- Offline ## Installation -This is a [Node.js](https://nodejs.org/) module available through the -[npm registry](https://www.npmjs.com/). It can be installed using the -[`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally) command line tools. +Module available through the [npm registry](https://www.npmjs.com/). It can be installed using the [`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally) or [`yarn`](https://yarnpkg.com/en/) command line tools. ```sh +# NPM npm install telegraf-test --save +# Or Using Yarn +yarn add telegraf-test ``` -## How to Use - -### Example +## Example -```javascript +```js const Telegraf = require('telegraf') const TelegrafTest = require('telegraf-test') @@ -38,34 +40,35 @@ const test = new TelegrafTest({ test.setUser({ id: 1234, - username: '@Jack' - //...// -}) /*return { + username: '@TiagoEDGE' + // ...// +}) /* Return { id: 1234, is_bot: false, first_name: 'FIST-NAME', last_name: '', - username: '@Jack', + username: '@TiagoEDGE', language_code: 'en-US' -}*/ +} */ -bot.hears(/ping/i, (ctx) => { +bot.hears(/ping/i, ctx => { ctx.reply('Pong!') }) bot.startWebhook(`/${secretPath}`, null, port) test.sendMessageWithText('/ping') - .then((res) => { + .then(res => { console.log(res.data) - //return { method: 'sendMessage', chat_id: 1234567890, text: 'Pong!' } + // { method: 'sendMessage', chat_id: 1234567890, text: 'Pong!' } }) - .catch((err) => { - console.error(err) + .catch(error => { + console.error(error) }) - ``` +## Documentation + ### Options of Class `TelegrafTest({options})` - **url** - String @@ -209,6 +212,17 @@ Run with `$ mocha --exit --timeout 100000` Set environment variables `DEBUG=telgraf:test`. +## Tests + +To run the test suite, first install the dependencies, then run `test`: + +```sh +# NPM +npm test +# Or Using Yarn +yarn test +``` + ## Dependencies - [axios](https://ghub.io/axios): Promise based HTTP client for the browser and node.js @@ -217,9 +231,14 @@ Set environment variables `DEBUG=telgraf:test`. ## Dev Dependencies -- [telegraf](https://ghub.io/telegraf): šŸ“” Modern Telegram bot framework - [mocha](https://ghub.io/mocha): simple, flexible, fun test framework +- [telegraf](https://ghub.io/telegraf): šŸ“” Modern Telegram Bot Framework +- [xo](https://ghub.io/xo): JavaScript happiness style linter ā¤ļø + +## Contributors + +Pull requests and stars are always welcome. For bugs and feature requests, please [create an issue](https://github.com/TiagoDanin/Telegraf-Test/issues). [List of all contributors](https://github.com/TiagoDanin/Telegraf-Test/graphs/contributors). ## License -MIT +[MIT](LICENSE) Ā© [Tiago Danin](https://TiagoDanin.github.io) \ No newline at end of file diff --git a/documentation.md b/documentation.md new file mode 100644 index 0000000..f2659a3 --- /dev/null +++ b/documentation.md @@ -0,0 +1,142 @@ +### Options of Class `TelegrafTest({options})` + +- **url** - String +> Webhook url of your bot.
+> Default value: `http://127.0.0.1:3000/secret-path` +- **axios** - Object +> Config/option of Axios.
+> Default value: `{headers: {'content-type': 'application/json'}, method: 'POST'}` +- **port** - Number +> Server emulator port.
+> Default value: `2000` +- **token** - String +> Bot token.
+> Default value: `ABCD:1234567890` + +### API + +#### Set & Get Objects + +- **setBot({**[params](https://core.telegram.org/bots/api#user)**})** +- **setUser({**[params](https://core.telegram.org/bots/api#user)**})** +- **setChat({**[params](https://core.telegram.org/bots/api#chat)**})** +- **setMessage({**[params](https://core.telegram.org/bots/api#message)**})** +- **setInlineQuery({**[params](https://core.telegram.org/bots/api#inlinequery)**})** +- **setCallbackQuery({**[params](https://core.telegram.org/bots/api#callbackquery)**})** +- **setUpdateId(id: Number)** +> Update id.
+> Default value: Start in `0` +- **setWebhook({**[params](https://core.telegram.org/bots/api#setwebhook)**})** +- **setAllowedUpdates({**[params](https://core.telegram.org/bots/api#update)**})** + +### Get Objects + +- **getUser()** +- **getChat()** +- **getMessage()** +- **getInlineQuery()** +- **getCallbackQuery()** +- **getUpdateId()** +- **getWebhook()** +- **getAllowedUpdates()** + +#### Send Requests + +Return request of [axios](https://github.com/axios/axios) or `false` in updates ignored. + +- **sendUpdate({**[params](https://core.telegram.org/bots/api#update)**})** +- **sendMessage({**[params](https://core.telegram.org/bots/api#message)**})** +- **sendMessageWithText(text: String, {**[params](https://core.telegram.org/bots/api#message)**})** +- **sendInlineQuery(query: String, {**[params](https://core.telegram.org/bots/api#inlinequery)**})** +- **sendCallbackQuery({**[params](https://core.telegram.org/bots/api#callbackquery)**})** +- **sendCallbackQueryWithData(data: String, {**[params](https://core.telegram.org/bots/api#callbackquery)**})** + +#### [WIP] Web Server + +Telegram Bot Api Server Emulator. Start with `startServer()`. + +- [x] [getMe](https://core.telegram.org/bots/api#getme) +- [x] [setWebhook](https://core.telegram.org/bots/api#setwebhook) +- [x] [getWebhookInfo](https://core.telegram.org/bots/api#deletewebhook) +- [x] [setWebhook](https://core.telegram.org/bots/api#getwebhookinfo) + + + +### Using with a Test Framework + +You create a test suite with +[Mocha](https://mochajs.org) and [ExpectJS](https://github.com/Automattic/expect.js). + +Example `test.js`: + +```javascript +const expect = require('expect.js') +describe('bot', function() { + it('/ping', async function() { + var r = await test.sendMessageWithText('/ping') + expect(r.data.text).to.be.a('string') + expect(r.data.text).to.contain('Pong!') + }) +}) +``` + +Run with `$ mocha --exit --timeout 100000` + +### Using Debug + +Set environment variables `DEBUG=telgraf:test`. diff --git a/example.js b/example.js new file mode 100644 index 0000000..ec32833 --- /dev/null +++ b/example.js @@ -0,0 +1,38 @@ +const Telegraf = require('telegraf') +const TelegrafTest = require('.') + +const port = 3000 +const secretPath = 'secret-path' + +const bot = new Telegraf('ABCD:1234567890') +const test = new TelegrafTest({ + url: `http://127.0.0.1:${port}/${secretPath}` +}) + +test.setUser({ + id: 1234, + username: '@TiagoEDGE' + // ...// +}) /* Return { + id: 1234, + is_bot: false, + first_name: 'FIST-NAME', + last_name: '', + username: '@TiagoEDGE', + language_code: 'en-US' +} */ + +bot.hears(/ping/i, ctx => { + ctx.reply('Pong!') +}) + +bot.startWebhook(`/${secretPath}`, null, port) + +test.sendMessageWithText('/ping') + .then(res => { + console.log(res.data) + // { method: 'sendMessage', chat_id: 1234567890, text: 'Pong!' } + }) + .catch(error => { + console.error(error) + }) diff --git a/index.js b/index.js index 4592ebf..96adbea 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const express = require('express') const log = debug('telegraf:test') class TelegrafTest { - constructor (options) { + constructor(options) { this.options = { url: 'http://127.0.0.1:3000/secret-path', axios: {}, @@ -27,8 +27,8 @@ class TelegrafTest { this.server = express() } - //Methods start in set** - setBot (bot) { + // Methods start in set** + setBot(bot) { this.bot = { id: 1234, is_bot: true, @@ -41,7 +41,7 @@ class TelegrafTest { return this.bot } - setUser (user) { + setUser(user) { this.user = { id: 1234567890, is_bot: false, @@ -56,7 +56,7 @@ class TelegrafTest { return this.user } - setChat (chat) { + setChat(chat) { this.chat = { id: 1234567890, type: 'private', // ā€œprivateā€, ā€œgroupā€, ā€œsupergroupā€ or ā€œchannelā€ @@ -72,29 +72,31 @@ class TelegrafTest { return this.chat } - setMessage (message) { - var message_id = 1 + setMessage(message) { + let message_id = 1 if (this.message && this.message.message_id) { message_id = Math.floor(this.message.message_id) + 1 } - //TODO: Add entities + + // TODO: Add entities this.message = { - message_id: message_id, + message_id, from: this.user, chat: this.chat, - date: `${+ new Date()}`, + date: `${Number(new Date())}`, ...message } return this.message } - setInlineQuery (inlineQuery) { - var id = 1 + setInlineQuery(inlineQuery) { + let id = 1 if (this.inline_query && this.inline_query.id) { id = Math.floor(id) + 1 } + this.inline_query = { - id: id, + id, from: this.user, query: '', offset: '', @@ -103,31 +105,32 @@ class TelegrafTest { return this.inline_query } - setCallbackQuery (callbackQuery) { - var id = 1 + setCallbackQuery(callbackQuery) { + let id = 1 if (this.callback_query && this.callback_query.id) { id = Math.floor(id) + 1 } + this.callback_query = { - id: id, + id, from: this.user, ...callbackQuery } return this.callback_query } - setUpdateId (id) { + setUpdateId(id) { this.updateId = Math.floor(id) log('New update id', this.updateId) return this.updateId } - setWebhook (webhook) { + setWebhook(webhook) { this.webhook = { url: '', has_custom_certificate: false, pending_update_count: 0, - last_error_date: `${+ new Date()}`, + last_error_date: `${Number(new Date())}`, last_error_message: 'Init Telegraf Test', max_connections: 40, allowed_updates: [ @@ -140,7 +143,7 @@ class TelegrafTest { return this.webhook } - setAllowedUpdates (updates) { + setAllowedUpdates(updates) { this.allowedUpdates = [ 'message', 'channel_post', @@ -154,56 +157,58 @@ class TelegrafTest { if (updates) { this.allowedUpdates = updates } + log('New allowedUpdates', this.allowedUpdates) return this.allowedUpdates } - //Methods start in get** - getBot () { + // Methods start in get** + getBot() { return this.bot } - getUser () { + getUser() { return this.user } - getChat () { + getChat() { return this.chat } - getMessage () { + getMessage() { return this.message } - getInlineQuery () { + getInlineQuery() { return this.inline_query } - getCallbackQuery () { + getCallbackQuery() { return this.callback_query } - getUpdateId () { + getUpdateId() { return this.updateId } - getWebhook () { + getWebhook() { return this.webhook } - getAllowedUpdates () { + getAllowedUpdates() { return this.allowedUpdates } - //Methods start in send** - sendUpdate (update) { + // Methods start in send** + sendUpdate(update) { this.updateId++ - var ignored = true - for (let updateType of this.allowedUpdates) { + let ignored = true + for (const updateType of this.allowedUpdates) { if (update[updateType]) { ignored = false } } + if (ignored) { log('Update ignored (check getAllowedUpdates()) ', { update_id: this.updateId, @@ -211,6 +216,7 @@ class TelegrafTest { }) return false } + log('Send via WebHook ', { update_id: this.updateId, ...update @@ -229,48 +235,48 @@ class TelegrafTest { }) } - sendMessage (options) { - var message = this.setMessage({ + sendMessage(options) { + const message = this.setMessage({ ...options }) - return this.sendUpdate({message: message}) + return this.sendUpdate({message}) } - sendMessageWithText (text, options) { - var message = this.setMessage({ - text: text, + sendMessageWithText(text, options) { + const message = this.setMessage({ + text, ...options }) - return this.sendUpdate({message: message}) + return this.sendUpdate({message}) } - sendInlineQuery (query, options) { - var inlineQuery = this.setInlineQuery({ - query: query, + sendInlineQuery(query, options) { + const inlineQuery = this.setInlineQuery({ + query, ...options }) return this.sendUpdate({inline_query: inlineQuery}) } - sendCallbackQuery (options) { - var callbackQuery = this.setCallbackQuery({ + sendCallbackQuery(options) { + const callbackQuery = this.setCallbackQuery({ ...options }) return this.sendUpdate({callback_query: callbackQuery}) } - sendCallbackQueryWithData (data, options) { - var callbackQuery = this.setCallbackQuery({ - data: data, + sendCallbackQueryWithData(data, options) { + const callbackQuery = this.setCallbackQuery({ + data, message: this.message, ...options }) return this.sendUpdate({callback_query: callbackQuery}) } - startServer () { + startServer() { this.server.get('/', (req, res) => { - var index = ` + const index = ` Hello World!
Web server of Telegraf Test by Tiago Danin
https://github.com/TiagoDanin/Telegraf-Test @@ -278,8 +284,8 @@ https://github.com/TiagoDanin/Telegraf-Test res.send(index) }) - var methods = { - getMe: (query) => { + const methods = { + getMe: () => { return { ok: true, result: { @@ -287,8 +293,8 @@ https://github.com/TiagoDanin/Telegraf-Test } } }, - setWebhook: (query) => { - var output = { + setWebhook: query => { + const output = { ok: true, result: true, description: 'Webhook is already deleted' @@ -296,17 +302,16 @@ https://github.com/TiagoDanin/Telegraf-Test if (query.length >= 1) { this.setWebhook(query) output.description = 'Webhook was set' - } else { - if (this.webhook.url != '') { - output.description = 'Webhook was deleted' - this.setWebhook({ - url: '' - }) - } + } else if (this.webhook.url !== '') { + output.description = 'Webhook was deleted' + this.setWebhook({ + url: '' + }) } + return output }, - deleteWebhook: (query) => { + deleteWebhook: () => { this.setWebhook({ url: '' }) @@ -316,7 +321,7 @@ https://github.com/TiagoDanin/Telegraf-Test description: 'Webhook was deleted' } }, - getWebhookInfo: (query) => { + getWebhookInfo: () => { return { ok: true, result: { @@ -325,7 +330,7 @@ https://github.com/TiagoDanin/Telegraf-Test } } /* - getUpdates: (query) => { + GetUpdates: (query) => { return JSON.stringify() }, sendMessage: (query) => { @@ -491,29 +496,29 @@ https://github.com/TiagoDanin/Telegraf-Test } this.server.get('/bot:token/:method', (req, res) => { - if (req.params.token != this.options.token) { + if (req.params.token !== this.options.token) { return res.json({ ok: false, error_code: 401, description: 'Unauthorized' }) } + if (methods[req.params.method]) { return res.json(methods[req.params.method](req.query)) - } else { - return res.json({ - ok: false, - error_code: 401, - description: 'Not Found: method not found in Telegraf Test' - }) } + + return res.json({ + ok: false, + error_code: 401, + description: 'Not Found: method not found in Telegraf Test' + }) }) this.server.listen(this.options.port, () => { log('Telegraf Test Server runnig in port: ', this.options.port) }) } - } module.exports = TelegrafTest diff --git a/package.json b/package.json index aec53b7..61ffc8c 100644 --- a/package.json +++ b/package.json @@ -1,39 +1,83 @@ { "name": "telegraf-test", + "main": "index.js", + "preferGlobal": false, "version": "1.1.0", "description": "Telegraf Test - Simple Test ToolKit of Telegram Bots", - "main": "index.js", - "dependencies": { - "axios": "^0.18.1", - "debug": "^4.1.1", - "express": "^4.17.1", - "snyk": "^1.161.1" - }, - "devDependencies": { - "telegraf": "^3.30.1", - "mocha": "6.1.4" + "author": { + "email": "TiagoDanin@outlook.com", + "name": "Tiago Danin", + "url": "https://TiagoDanin.github.io" }, + "license": "MIT", + "keywords": [ + "localhost", + "mocha", + "offline", + "sendmessage", + "telegraf", + "telegram", + "telegram-bot", + "telegram-test", + "test", + "test-automation", + "test-framework", + "testing", + "testing-tools", + "tests" + ], "scripts": { - "test": "mocha --exit --timeout 100000", - "snyk-protect": "snyk protect", - "prepublish": "npm run snyk-protect" + "start": "node index.js", + "test": "xo && mocha --exit --timeout 100000" }, + "engines": { + "node": ">=8" + }, + "private": false, "repository": { "type": "git", "url": "git+https://github.com/TiagoDanin/Telegraf-Test.git" }, - "keywords": [ - "telegraf", - "test", - "telegram", - "framework", - "toolkit" - ], - "author": "Tiago Danin", - "license": "MIT", + "homepage": "https://TiagoDanin.github.io/Telegraf-Test", "bugs": { "url": "https://github.com/TiagoDanin/Telegraf-Test/issues" }, - "homepage": "https://github.com/TiagoDanin/Telegraf-Test#readme", - "snyk": true + "github": { + "name": "Telegraf-Test", + "owner": "TiagoDanin" + }, + "files": [ + "LICENSE", + "README.md", + "index.js", + "package.json" + ], + "dependencies": { + "axios": "^0.18.1", + "debug": "^4.1.1", + "express": "^4.17.1" + }, + "devDependencies": { + "mocha": "6.1.4", + "telegraf": "^3.30.1", + "xo": "0.24.0" + }, + "xo": { + "rules": { + "quote-props": "warn", + "eqeqeq": "warn", + "array-callback-return": "warn", + "require-atomic-updates": "warn", + "camelcase": "off" + }, + "semicolon": false + }, + "features": [ + "Telegram bot api server emulator.", + "Compatible with Telegraf <3.", + "Compatible with Mocha e others test framework.", + "Send message, inline query and callback query.", + "Work in local network.", + "Offline" + ] } diff --git a/test.js b/test.js index afeac60..636a07a 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ +/* eslint-disable no-undef */ +const assert = require('assert') const Telegraf = require('telegraf') const TelegrafTest = require('.') -const assert = require('assert') const port = 3000 const secretPath = 'secret-path' @@ -11,11 +12,11 @@ const test = new TelegrafTest({ }) test.startServer() -bot.hears(/ping/i, (ctx) => { +bot.hears(/ping/i, ctx => { ctx.reply('Pong!') }) -bot.on('inline_query', (ctx) => { +bot.on('inline_query', ctx => { ctx.answerInlineQuery([{ type: 'article', title: 'TITLE', @@ -28,7 +29,7 @@ bot.on('inline_query', (ctx) => { }) }) -bot.on('callback_query', (ctx) => { +bot.on('callback_query', ctx => { ctx.answerCbQuery( 'Testā€¼ļø', true @@ -37,67 +38,67 @@ bot.on('callback_query', (ctx) => { bot.startWebhook(`/${secretPath}`, null, port) -describe('Telegraf Test', function() { - it('setBot()', async function() { - var bot = test.setBot({ +describe('Telegraf Test', () => { + it('setBot()', async () => { + const bot = test.setBot({ username: 'Tiagobot' }) - assert.equal(bot.username, 'Tiagobot') + assert.strictEqual(bot.username, 'Tiagobot') }) - it('setUser()', async function() { - var user = test.setUser({ + it('setUser()', async () => { + const user = test.setUser({ id: 1234, username: '@Jack' }) - assert.equal(user.id, 1234) - assert.equal(user.username, '@Jack') + assert.strictEqual(user.id, 1234) + assert.strictEqual(user.username, '@Jack') }) - it('setChat()', async function() { - var chat = test.setChat({ + it('setChat()', async () => { + const chat = test.setChat({ id: 6655465, type: 'supergroup' }) - assert.equal(chat.id, 6655465) - assert.equal(chat.type, 'supergroup') + assert.strictEqual(chat.id, 6655465) + assert.strictEqual(chat.type, 'supergroup') }) - it('setMessage()', async function() { - var message = test.setMessage({}) - assert.equal(message.message_id, 2) - assert.equal(message.from.username, '@Jack') + it('setMessage()', async () => { + const message = test.setMessage({}) + assert.strictEqual(message.message_id, 2) + assert.strictEqual(message.from.username, '@Jack') }) - it('setMessage()', async function() { - var message = test.setMessage({}) - assert.equal(message.from.username, '@Jack') + it('setMessage()', async () => { + const message = test.setMessage({}) + assert.strictEqual(message.from.username, '@Jack') }) - it('setInlineQuery()', async function() { - var inline = test.setInlineQuery({}) - assert.equal(inline.from.username, '@Jack') + it('setInlineQuery()', async () => { + const inline = test.setInlineQuery({}) + assert.strictEqual(inline.from.username, '@Jack') }) - it('setCallbackQuery()', async function() { - var callback = test.setCallbackQuery({}) - assert.equal(callback.from.username, '@Jack') + it('setCallbackQuery()', async () => { + const callback = test.setCallbackQuery({}) + assert.strictEqual(callback.from.username, '@Jack') }) - it('setUpdateId()', async function() { - var id = test.setUpdateId(6) - assert.equal(id, 6) + it('setUpdateId()', async () => { + const id = test.setUpdateId(6) + assert.strictEqual(id, 6) }) - it('setWebhook()', async function() { - var webhook = test.setWebhook() - assert.equal(webhook.url, test.webhook.url) - assert.equal(webhook.allowed_updates.toString(), test.getAllowedUpdates().toString()) + it('setWebhook()', async () => { + const webhook = test.setWebhook() + assert.strictEqual(webhook.url, test.webhook.url) + assert.strictEqual(webhook.allowed_updates.toString(), test.getAllowedUpdates().toString()) }) - it('setAllowedUpdates()', async function() { - var updatesType = test.setAllowedUpdates() - assert.equal(updatesType.toString(), [ + it('setAllowedUpdates()', async () => { + const updatesType = test.setAllowedUpdates() + assert.strictEqual(updatesType.toString(), [ 'message', 'channel_post', 'edited_channel_post', @@ -109,76 +110,76 @@ describe('Telegraf Test', function() { ].toString()) }) - it('getBot', async function() { - assert.equal(test.getBot(), test.bot) + it('getBot', async () => { + assert.strictEqual(test.getBot(), test.bot) }) - it('getUser', async function() { - assert.equal(test.getUser(), test.user) + it('getUser', async () => { + assert.strictEqual(test.getUser(), test.user) }) - it('getChat', async function() { - assert.equal(test.getChat(), test.chat) + it('getChat', async () => { + assert.strictEqual(test.getChat(), test.chat) }) - it('getMessage', async function() { - assert.equal(test.getMessage(), test.message) + it('getMessage', async () => { + assert.strictEqual(test.getMessage(), test.message) }) - it('getInlineQuery', async function() { - assert.equal(test.getInlineQuery(), test.inline_query) + it('getInlineQuery', async () => { + assert.strictEqual(test.getInlineQuery(), test.inline_query) }) - it('getCallbackQuery', async function() { - assert.equal(test.getCallbackQuery(), test.callback_query) + it('getCallbackQuery', async () => { + assert.strictEqual(test.getCallbackQuery(), test.callback_query) }) - it('getUpdateId', async function() { - assert.equal(test.getUpdateId(), test.updateId) + it('getUpdateId', async () => { + assert.strictEqual(test.getUpdateId(), test.updateId) }) - it('getWebhook', async function() { - assert.equal(test.getWebhook(), test.webhook) + it('getWebhook', async () => { + assert.strictEqual(test.getWebhook(), test.webhook) }) - it('getAllowedUpdates', async function() { - assert.equal(test.getAllowedUpdates(), test.allowedUpdates) + it('getAllowedUpdates', async () => { + assert.strictEqual(test.getAllowedUpdates(), test.allowedUpdates) }) - it('sendUpdate()', async function() { - var r = await test.sendUpdate({}) - assert.equal(r, false) + it('sendUpdate()', async () => { + const r = await test.sendUpdate({}) + assert.strictEqual(r, false) }) - it('sendMessage()', async function() { - var r = await test.sendMessage({ + it('sendMessage()', async () => { + const r = await test.sendMessage({ text: '/ping' }) - assert.equal(r.data.text, 'Pong!') + assert.strictEqual(r.data.text, 'Pong!') }) - it('sendMessageWithText()', async function() { - var r = await test.sendMessageWithText('/ping') - assert.equal(r.data.text, 'Pong!') + it('sendMessageWithText()', async () => { + const r = await test.sendMessageWithText('/ping') + assert.strictEqual(r.data.text, 'Pong!') }) - it('sendInlineQuery()', async function() { - var r = await test.sendInlineQuery('hi!') - assert.equal(r.data.method, 'answerInlineQuery') - assert.equal(r.data.cache_time, 0) + it('sendInlineQuery()', async () => { + const r = await test.sendInlineQuery('hi!') + assert.strictEqual(r.data.method, 'answerInlineQuery') + assert.strictEqual(r.data.cache_time, 0) }) - it('sendCallbackQuery()', async function() { - var r = await test.sendCallbackQueryWithData({ + it('sendCallbackQuery()', async () => { + const r = await test.sendCallbackQueryWithData({ data: 'test' }) - assert.equal(r.data.method, 'answerCallbackQuery') - assert.equal(r.data.text, 'Testā€¼ļø') + assert.strictEqual(r.data.method, 'answerCallbackQuery') + assert.strictEqual(r.data.text, 'Testā€¼ļø') }) - it('sendCallbackQueryWithData()', async function() { - var r = await test.sendCallbackQueryWithData('test') - assert.equal(r.data.method, 'answerCallbackQuery') - assert.equal(r.data.text, 'Testā€¼ļø') + it('sendCallbackQueryWithData()', async () => { + const r = await test.sendCallbackQueryWithData('test') + assert.strictEqual(r.data.method, 'answerCallbackQuery') + assert.strictEqual(r.data.text, 'Testā€¼ļø') }) })