const { describe, it } = require('mocha')
const Bot = require('..')
// const assert = require('assert')

const peer = process.env.TEST_PEER_ID
const token = process.env.TEST_VK_TOKEN

describe('Bot', function () {
  var engbot, rusbot, bot, pollingbot, oldVersionBot

  bot = new Bot({ token })
  engbot = new Bot({
    token,
    api: { lang: 'en' }
  })
  rusbot = new Bot({
    token,
    api: { lang: 'ru' }
  })
  oldVersionBot = new Bot({ token, api: { v: 5.37 } })
  pollingbot = new Bot({ token })
  pollingbot.start()

  describe('Events', function () {
    it('Emits "update" on recieved message', (done) => {
      pollingbot.once('update', () => done())
      pollingbot.send('Test message', peer)
    })
  })

  describe('#send', function () {
    it('Sends message', function () {
      return bot.send('Test message 2', peer)
    })
  })

  describe('#api', function () {
    describe('Languages', function () {
      it('Gets response in Russian', function () {
        return rusbot.api('users.get', { user_ids: 1 })
          .then(res => res[0])
          .then(durov => {
            if (durov.first_name !== 'Павел') throw new Error()
          })
      })
      it('Gets response in English', function () {
        return engbot.api('users.get', { user_ids: 1 })
          .then(res => res[0])
          .then(durov => {
            if (durov.first_name !== 'Pavel') throw new Error()
          })
      })
    })

    describe('Versions', function () {
      it('Gets error when using peer_id on version 5.37', function () {
        return oldVersionBot.api('messages.send', {
          peer_id: peer,
          message: '123'
        }).then(() => false, () => true)
      })
    })
  })
})

@@ -64,44 +64,8 @@
 ..')
-%0A// const assert = require('assert')
 %0A%0Aco
@@ -177,61 +177,13 @@
 %7B%0A  
-var engbot, rusbot, bot, pollingbot, oldVersionBot%0A%0A 
+const
  bot
@@ -206,16 +206,25 @@
 en %7D)%0A  
+%0A  const 
 engbot =
@@ -229,39 +229,31 @@
  = new Bot(%7B
-%0A   
  token,
-%0A   
  api: %7B lang
@@ -260,24 +260,28 @@
 : 'en' %7D
-%0A 
  %7D)%0A  
+const 
 rusbot =
@@ -294,23 +294,15 @@
 ot(%7B
-%0A   
  token,
-%0A   
  api
@@ -321,16 +321,23 @@
 u' %7D
-%0A 
  %7D)%0A  
+%0A  const 
 oldV
@@ -383,24 +383,33 @@
 5.37 %7D %7D)%0A  
+%0A  const 
 pollingbot =
@@ -588,16 +588,48 @@
 done())%0A
+      setTimeout(function() %7B%0A  
       po
@@ -656,32 +656,95 @@
 message', peer)%0A
+      %7D, 1000) // because sometimes it doesn't work %C2%AF%5C_(%E3%83%84)_/%C2%AF %0A
     %7D)%0A  %7D)%0A%0A  d

fix tests (should work)