text: const Token = artifacts.require("MyToken");
  const TokenSale = artifacts.require("MyTokenSale");
  const KycContract = artifacts.require("KycContract");
  
  const chai = require("./chaisetup.js");
  const BN = web3.utils.BN;
  const expect = chai.expect;
  
  var chai = require("chai");
  const expect = chai.expect;
  
  const BN = web3.utils.BN;
  const chaiBN = require('chai-bn')(BN);
  chai.use(chaiBN);
  
  var chaiAsPromised = require("chai-as-promised");
  chai.use(chaiAsPromised);
  
  contract("Token Test", async accounts => {
      const [initialHolder, recipient, anotherAccount] = accounts;
  
  
      it("All tokens should be in my account", async () => {
          let instance = await Token.deployed();
          let totalSupply = await instance.totalSupply();
          return expect(instance.balanceOf.call(initialHolder)).to.eventually.be.a.bignumber.equal(new BN(0));
          //old style:
          //let balance = await instance.balanceOf.call(initialHolder);
          //assert.equal(balance.valueOf(), 0, "Account 1 has a balance");
          //condensed, easier readable style:
          await expect(instance.balanceOf(initialHolder)).to.eventually.be.a.bignumber.equal(totalSupply);
      });
  });
      it("I can send tokens from Account 1 to Account 2", async () => {
          const sendTokens = 1;
          let instance = await Token.deployed();
          let totalSupply = await instance.totalSupply();
          await expect(instance.balanceOf(initialHolder)).to.eventually.be.a.bignumber.equal(totalSupply);
          await expect(instance.transfer(recipient, sendTokens)).to.eventually.be.fulfilled;
          await expect(instance.balanceOf(initialHolder)).to.eventually.be.a.bignumber.equal(totalSupply.sub(new BN(sendTokens)));
          await expect(instance.balanceOf(recipient)).to.eventually.be.a.bignumber.equal(new BN(sendTokens));
      });
  
  
      it("It's not possible to send more tokens than account 1 has", async () => {
          let instance = await Token.deployed();
          let balanceOfAccount = await instance.balanceOf(initialHolder);
          await expect(instance.transfer(recipient, new BN(balanceOfAccount + 1))).to.eventually.be.rejected;
  
          //check if the balance is still the same
          await expect(instance.balanceOf(initialHolder)).to.eventually.be.a.bignumber.equal(balanceOfAccount);
  
      });
  it("all coins should be in the tokensale smart contract", async () => {
      let instance = await Token.deployed();
      let balance = await instance.balanceOf.call(TokenSale.address);
      let totalSupply = await instance.totalSupply.call();
      return expect(balance).to.be.a.bignumber.equal(totalSupply);
  });
  
  it("should be possible to buy one token by simply sending ether to the smart contract", async () => {
      let tokenInstance = await Token.deployed();
      let tokenSaleInstance = await TokenSale.deployed();
      let balanceBeforeAccount = await tokenInstance.balanceOf.call(recipient); await expect(tokenSaleInstance.sendTransaction({ from: recipient, value: web3.utils.toWei("1", "wei") })).to.be.rejected;
      await expect(balanceBeforeAccount).to.be.bignumber.equal(await tokenInstance.balanceOf.call(recipient));
  
      let kycInstance = await KycContract.deployed();
      await kycInstance.setKycCompleted(recipient);
      await expect(tokenSaleInstance.sendTransaction({ from: recipient, value: web3.utils.toWei("1", "wei") })).to.be.fulfilled;
      return expect(balanceBeforeAccount + 1).to.be.bignumber.equal(await tokenInstance.balanceOf.call(recipient));
  
  });
  //...