describe('#sendChatAction', function sendChatActionSuite() { before(function before() { utils.handleRatelimit(bot, 'sendChatAction', this); }); it('should send a chat action', function test() { const action = 'typing'; return bot.sendChatAction(USERID, action).then(resp => { assert.equal(resp, true); }); }); });
it('should create error when passing invalid url', function() { var response = queue.addToQueue({ url: '$#$#@%@#' }) assert(response.error) assert.equal(response.code, error.getErrorCode(error.ERROR_INVALID_URL)) })
describe('module.exports', function moduleExportsSuite() { const nodeVersion = parseInt(process.versions.node.split('.')[0], 10); it('is loaded from src/ on Node.js v6+ and above', function test() { if (nodeVersion <= 5) this.skip(); // skip on Node.js v5 and below assert.equal(TelegramBot, require('../src/telegram')); }); it('is loaded from lib/ on Node.js v5 and below', function test() { if (nodeVersion > 5) this.skip(); // skip on newer versions assert.equal(TelegramBot, require('../lib/telegram')); }); });
it('should return the correct job by id', function() { queue = createQueue({}, [ createJob(true), Object.assign(createJob(true), { meta: { correct: true } }), createJob(true) ]) return queue.getById(2).then(function (job) { assert.equal(job.meta.correct, true) }) })
it('should limit', function() { var jobs = [] for(var i = 0; i <= 20; i++) { jobs.push(createJob(false)) } queue = createQueue({}, jobs) return queue.getList(false, false, 10).then(function (list) { assert.equal(list.length, 10) }) })
describe('#setChatTitle', function setChatTitleSuite() { before(function before() { utils.handleRatelimit(bot, 'setChatTitle', this); }); it('should set the chat title', function test() { const random = Math.floor(Math.random() * 1000); return bot.setChatTitle(GROUPID, `ntba test group (random: ${random})`).then(resp => { assert.equal(resp, true); }); }); });
it('should create error when passing invalid meta', function() { var response = queue.addToQueue({ meta: 'not-object', url: 'http://localhost' }) assert(response.error) assert.equal(response.code, error.getErrorCode(error.ERROR_META_IS_NOT_OBJECT)) })
describe('#deleteWebHook', function deleteWebHookSuite() { before(function before() { utils.handleRatelimit(bot, 'deleteWebHook', this); }); it('should delete webhook', function test() { return bot.deleteWebHook().then(resp => { assert.equal(resp, true); }); }); });
describe('#setChatDescription', function setChatDescriptionSuite() { before(function before() { utils.handleRatelimit(bot, 'setChatDescription', this); }); it('should set the chat description', function test() { const random = Math.floor(Math.random() * 1000); const description = `node-telegram-bot-api test group (random: ${random})`; return bot.setChatDescription(GROUPID, description).then(resp => { assert.equal(resp, true); }); }); });
describe('#deleteChatPhoto', function deleteChatPhotoSuite() { before(function before() { utils.handleRatelimit(bot, 'deleteChatPhoto', this); }); it('should delete the chat photo', function test() { return bot.deleteChatPhoto(GROUPID).then(resp => { assert.equal(resp, true); }); }); });
describe('#unpinChatMessage', function unpinChatMessageSuite() { before(function before() { utils.handleRatelimit(bot, 'unpinChatMessage', this); }); it('should unpin chat message', function test() { return bot.unpinChatMessage(GROUPID).then(resp => { assert.equal(resp, true); }); }); });