/* eslint-disable no-unused-expressions */
const {expect} = require('chai');
const pkg = require('../');

describe('PubgAPI', () => {
  const apikey = process.env.PUBG_APIKEY;

  describe('when created', () => {
    it('should export PubgAPI and PubgAPIErrors', () => {
      expect(pkg.PubgAPI).to.exist;
      expect(pkg.PubgAPIErrors).to.exist;
    });

    it('should initialize with api key and no cache', () => {
      const {PubgAPI} = pkg;
      const api = new PubgAPI(apikey);

      expect(api).to.be.instanceOf(PubgAPI);
    });

    it('should fail with no apikey', () => {
      try {
        const {PubgAPI} = pkg;
        // eslint-disable-next-line
        const api = new PubgAPI(null);
      } catch (err) {
        expect(err).to.be.instanceOf(pkg.PubgAPIErrors.EmptyApiKey);
      }
    });

    it('should have pubg-tracker-api methods', () => {
      const {PubgAPI} = pkg;
      const api = new PubgAPI(apikey);

      expect(api.getProfileByNickname).to.exist;
      expect(api.getAccountBySteamID).to.exist;
    });
  });

  describe('when getProfileByNickname', () => {
    const nickname = 'javilobo8';
    const {PubgAPI} = pkg;
    const api = new PubgAPI(apikey);

    it('should get profile object', (done) => {
      api.getProfileByNickname(nickname)
        .then((profile) => {
          const stats = profile.getStats();
          expect(profile.content).to.exist;
          expect(stats).to.exist;
          done();
        });
    });
  });

  describe('when getAccountBySteamID', () => {
    const steamId = '76561198084956266';
    const {PubgAPI} = pkg;
    const api = new PubgAPI(apikey);

    it('should get account data', (done) => {
      api.getAccountBySteamID(steamId)
        .then((data) => {
          expect(data).to.exist;
          done();
        });
    });
  });
});

@@ -463,38 +463,40 @@
 i = new PubgAPI(
+%7B
 apikey
+%7D
 );%0A%0A      expect
@@ -697,12 +697,10 @@
 API(
-null
+%7B%7D
 );%0A 
@@ -912,38 +912,40 @@
 i = new PubgAPI(
+%7B
 apikey
+%7D
 );%0A%0A      expect
@@ -1173,38 +1173,40 @@
 i = new PubgAPI(
+%7B
 apikey
+%7D
 );%0A%0A    it('shou
@@ -1621,22 +1621,24 @@
 PubgAPI(
+%7B
 apikey
+%7D
 );%0A%0A    

fix tests