describe('#sendMessage', function sendMessageSuite() { before(function before() { utils.handleRatelimit(bot, 'sendMessage', this); }); it('should send a message', function test() { return bot.sendMessage(USERID, 'test').then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.message_id)); }); }); });
describe('#editMessageLiveLocation', function editMessageLiveLocationSuite() { let message; before(function before() { utils.handleRatelimit(bot, 'editMessageLiveLocation', this); const opts = { live_period: 86400 }; return bot.sendLocation(USERID, lat, long, opts).then(resp => { message = resp; }); }); it('edits live location', function test() { const opts = { chat_id: USERID, message_id: message.message_id }; return bot.editMessageLiveLocation(lat + 1, long + 1, opts).then(resp => { assert.ok(is.object(resp)); assert.ok(is.object(resp.location)); assert.ok(is.number(resp.location.latitude)); assert.ok(is.number(resp.location.longitude)); }); }); });
describe('#forwardMessage', function forwardMessageSuite() { before(function before() { utils.handleRatelimit(bot, 'sendMessage', this); utils.handleRatelimit(bot, 'forwardMessage', this); }); it('should forward a message', function test() { return bot.sendMessage(USERID, 'test').then(resp => { const messageId = resp.message_id; return bot.forwardMessage(USERID, USERID, messageId) .then(forwarded => { assert.ok(is.object(forwarded)); assert.ok(is.number(forwarded.message_id)); }); }); }); });
describe('#sendVenue', function sendVenueSuite() { before(function before() { utils.handleRatelimit(bot, 'sendVenue', this); }); it('should send a venue', function test() { const title = 'The Village Shopping Centre'; const address = '430 Topsail Rd,St. John\'s, NL A1E 4N1, Canada'; return bot.sendVenue(USERID, lat, long, title, address).then(resp => { assert.ok(is.object(resp)); assert.ok(is.object(resp.venue)); assert.ok(is.object(resp.venue.location)); assert.ok(is.number(resp.venue.location.latitude)); assert.ok(is.number(resp.venue.location.longitude)); assert.ok(is.string(resp.venue.title)); assert.ok(is.string(resp.venue.address)); }); }); });
describe('#getUserProfilePhotos', function getUserProfilePhotosSuite() { const opts = { offset: 0, limit: 1, }; before(function before() { utils.handleRatelimit(bot, 'getUserProfilePhotos', this); }); it('should get user profile photos', function test() { return bot.getUserProfilePhotos(USERID, opts).then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.total_count)); assert.ok(is.array(resp.photos)); }); }); it('(v0.25.0 and lower) should get user profile photos', function test() { return bot.getUserProfilePhotos(USERID, opts.offset, opts.limit).then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.total_count)); assert.ok(is.array(resp.photos)); }); }); });
describe('#sendInvoice', function sendInvoiceSuite() { before(function before() { utils.handleRatelimit(bot, 'sendInvoice', this); }); it('should send an invoice', function test() { if (isCI) { this.skip(); // Skip test for now } const title = 'Demo product'; const description = 'our test product'; const payload = 'sku-p001'; const providerToken = PROVIDER_TOKEN; const startParameter = 'pay'; const currency = 'USD'; const prices = [{ label: 'product', amount: 11000 }, { label: 'tax', amount: 11000 }]; return bot.sendInvoice(USERID, title, description, payload, providerToken, startParameter, currency, prices).then(resp => { assert.ok(is.object(resp)); assert.ok(is.object(resp.invoice)); assert.ok(is.number(resp.invoice.total_amount)); }); }); });
describe('#sendLocation', function sendLocationSuite() { before(function before() { utils.handleRatelimit(bot, 'sendLocation', this); }); it('should send a location', function test() { return bot.sendLocation(USERID, lat, long).then(resp => { assert.ok(is.object(resp)); assert.ok(is.object(resp.location)); assert.ok(is.number(resp.location.latitude)); assert.ok(is.number(resp.location.longitude)); }); }); });
describe('#getWebHookInfo', function getWebHookInfoSuite() { before(function before() { utils.handleRatelimit(bot, 'getWebHookInfo', this); }); it('should return WebhookInfo', function test() { return bot.getWebHookInfo().then(resp => { assert.ok(is.object(resp)); assert.ok(is.boolean(resp.has_custom_certificate)); assert.ok(is.number(resp.pending_update_count)); }); }); });
describe.skip('#stopMessageLiveLocation', function editMessageLiveLocationSuite() { let message; before(function before() { utils.handleRatelimit(bot, 'stopMessageLiveLocation', this); return bot.sendLocation(USERID, lat, long, { live_period: 86400 }) .then((resp) => { message = resp; }); }); it('stops location updates', function test() { const opts = { chat_id: USERID, message_id: message.message_id }; return bot.stopMessageLiveLocation(opts).then(resp => { assert.ok(is.object(resp)); assert.ok(is.object(resp.location)); assert.ok(is.number(resp.location.latitude)); assert.ok(is.number(resp.location.longitude)); }); }); });
describe('#getMe', function getMeSuite() { before(function before() { utils.handleRatelimit(bot, 'getMe', this); }); it('should return an User object', function test() { return bot.getMe().then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.id)); assert.ok(is.string(resp.first_name)); }); }); });
constructor(option) { super(option); this.effect = this.transition.effect || 'linear'; if (is.string(this.effect)) { this.effect = Effects[this.effect]; } if (!is.fn(this.effect)) { throw 'Invalid effect ' + this.transition.effect; } this.duration = this.transition.duration || 500; if (!is.number(this.duration)) { throw 'Invalid duration ' + this.transition.duration; } this.from = this.transition.from || {}; this.keepTarget = this.transition.keepTarget === true; this.target = this.transition.target || Util.assignWithout({}, ['effect', 'duration', 'from'], this.transition); this._targetCssNames = Object.keys(this.target); this._fromCssNames = Object.keys(this.from); this._cssNames = array.uniquePush.apply(null, [[]].concat(this._targetCssNames).concat(this._fromCssNames)); }
if (is.number(options.timeout)) { timeout = Math.min(Math.max(options.timeout, 0), 600);