<commit_before>import "babel-polyfill";
import expect from 'expect.js';

import TelegramBotApi from './telegram-bot-core';

const
token = process.env.TEST_TOKEN || '<KEY>',
userId = process.env.TEST_USERID || 777000,

expectToBePromise = (obj) => {
  expect(obj).to.be.an('object');
  expect(obj).to.have.property('then');
  expect(obj.then).to.be.a('function');
}
;

describe('telegram-bot-core', () => {
  var bot;

  describe('new instance', () => {

    it('should an constructor', () => {
      expect(TelegramBotApi).to.be.a('function');
      expect(new TelegramBotApi()).to.be.an('object');
    });

    it('should have token', () => {
      let bot = new TelegramBotApi(token);
      expect(bot.token).to.be.equal(token);
    });

    it('should have not token by default', () => {
      let bot = new TelegramBotApi();
      expect(bot.token).to.be.empty();
    });

    it('should not have any option', () => {
      let bot = new TelegramBotApi(token, {});
      expect(bot.options).to.be(undefined);
    });

  });

  describe('makeUrl', () => {

    it('should exist', () => {
      let bot = new TelegramBotApi('123456');
      expect(bot).to.have.property('makeUrl');
    });

    it('should return correct url', () => {
      let bot = new TelegramBotApi('123456');
      expect(bot.makeUrl('getMe')).to.be.equal('https://api.telegram.org/bot123456/getMe');
    });
  });

  before(() => {
    bot = new TelegramBotApi(token);
    return bot;
  });

  describe('query', () => {

    it('should exist', () => {
      expect(bot).to.have.property('query');
    });

    it('should a function', () => {
      expect(bot.query).to.be.a('function');
    });

    it('should return promise', () => {
      var queryRes = bot.query('getMe', {});
      expectToBePromise(queryRes);
    })

    it('should work with getMe', (done) => {
      bot.query('getMe', {})
      .then((data) => {
        expect(data).to.be.ok();
        done();
      }, done);
    });

    it('should return pased json', (done) => {
      bot.query('getMe', {})
      .then((data) => {
        expect(data).to.be.an('object');
        expect(data).to.have.property('ok');
        done();<commit_msg>fix(test): fox getMe tets bug<commit_after>import "babel-polyfill";
import expect from 'expect.js';

import TelegramBotApi from './telegram-bot-core';

const
token = process.env.TEST_TOKEN || '<KEY>',
userId = process.env.TEST_USERID || 777000,

expectToBePromise = (obj) => {
  expect(obj).to.be.an('object');
  expect(obj).to.have.property('then');
  expect(obj.then).to.be.a('function');
}
;

describe('telegram-bot-core', () => {
  var bot;

  describe('new instance', () => {

    it('should an constructor', () => {
      expect(TelegramBotApi).to.be.a('function');
      expect(new TelegramBotApi()).to.be.an('object');
    });

    it('should have token', () => {
      let bot = new TelegramBotApi(token);
      expect(bot.token).to.be.equal(token);
    });

    it('should have not token by default', () => {
      let bot = new TelegramBotApi();
      expect(bot.token).to.be.empty();
    });

    it('should not have any option', () => {
      let bot = new TelegramBotApi(token, {});
      expect(bot.options).to.be(undefined);
    });

  });

  describe('makeUrl', () => {

    it('should exist', () => {
      let bot = new TelegramBotApi('123456');
      expect(bot).to.have.property('makeUrl');
    });

    it('should return correct url', () => {
      let bot = new TelegramBotApi('123456');
      expect(bot.makeUrl('getMe')).to.be.equal('https://api.telegram.org/bot123456/getMe');
    });
  });

  before(() => {
    bot = new TelegramBotApi(token);
    return bot;
  });

  describe('query', () => {

    it('should exist', () => {
      expect(bot).to.have.property('query');
    });

    it('should a function', () => {
      expect(bot.query).to.be.a('function');
    });

    it('should return promise', () => {
      var queryRes = bot.query('getMe', {});
      expectToBePromise(queryRes);
    })

    it('should work with getMe', (done) => {
      bot.query('getMe')
      .then((data) => {
        expect(data).to.be.ok();
        done();
      }, done);
    });

    it('should return pased json', (done) => {
      bot.query('getMe')
      .then((data) => {
        expect(data).to.be.an('object');
        expect(data).to.have.property('ok');
        done();
{'fraction_non_alphanumeric': 0.2136654478976234, 'fraction_numerical': 0.010968921389396709, 'mean_word_length': 2.7961838681699915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2987871', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1449, 'n_words': 243}