import 'dotenv/config';
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import WorldOfTanks from '../../../src/clients/WorldOfTanks';

describe('Tankopedia', function() {
  const client = new WorldOfTanks({
    realm: 'na',
    applicationId: process.env.APPLICATION_ID,
  });

  before(function() {
    chai.use(chaiAsPromised);
  });

  describe('#findVehicle()', function() {
    it('finds vehicles by ID', function() {
      return expect(client.tankopedia.findVehicle(6673)).to.eventually.have.property('name', 'Marder II');
    });

    it('finds vehicles by long name', function() {
      return expect(client.tankopedia.findVehicle('m10 wolverine')).to.eventually.have.property('name', 'M10 Wolverine');
    });

    it('finds vehicles by short name', function() {
      return expect(client.tankopedia.findVehicle('centurion ax')).to.eventually.have.property('short_name', 'Centurion AX');
    });

    it('finds vehicles by partial match - long name', function() {
      return expect(client.tankopedia.findVehicle('bat-chatillon')).to.eventually.have.property('name', 'Bat.-Châtillon 25 t');
    });

    it('finds vehicles by partial match - short name', function() {
      return expect(client.tankopedia.findVehicle('vae')).to.eventually.have.property('short_name', 'VAE Type B');
    });

    it('throws for invalid identifier types', function() {
      expect(() => client.tankopedia.findVehicle({})).to.throw(Error);
    });
  });
});

@@ -200,16 +200,119 @@
 ion() %7B%0A
+  before(function() %7B%0A    chai.use(chaiAsPromised);%0A  %7D);%0A%0A  describe('#findVehicle()', function() %7B%0A  
   const 
@@ -343,16 +343,18 @@
 s(%7B%0A    
+  
 realm: '
@@ -358,16 +358,18 @@
 : 'na',%0A
+  
     appl
@@ -407,16 +407,18 @@
 ION_ID,%0A
+  
   %7D);%0A%0A 
@@ -422,106 +422,98 @@
 %0A%0A  
-before(function() %7B%0A    chai.use(chaiAsPromised);%0A  %7D);%0A%0A  describe('#findVehicle()', function() %7B
+  // need to wait quite a bit when the API response is not cached%0A    this.timeout(5000);%0A
 %0A   

Increase timeout for Tankopedia tests to compensate for API response delay.