text: const assert = require('assert');
  const ganache = require('ganache-cli');
  const Web3 = require('Web3');
  const web3 = new Web3(ganache.provider());
  
  const compiledFactory = require('../ethereum/build/CampaignFactory.json');
  const compiledCampaign = require('../ethereum/build/Campaign.json');
  
  let accounts;
  let factory;
  let campaignAddress;
  let campaign;
  
  beforeEach(async () => {
      accounts = await web3.eth.getAccounts();
  
      factory = await new web3.eth.Contract(JSON.parse(compiledFactory.interface))
          .deploy({ data: compiledFactory.bytecode })
          .send({ from: accounts[0], gas: '1000000' });
  
      await factory.methods.createCampaign('100').send({
          from: accounts[0],
          gas: '1000000'
      });
      // use `.call()` on view functions
      [campaignAddress] = await factory.methods.getDeployedCampaigns().call();
      // this contract is already deployed by the first
      // we just provide the address of that contract to inform solidity
      campaign = await new web3.eth.Contract(
          JSON.parse(compiledCampaign.interface), // ABI
          campaignAddress
      );
  });
  
  describe('Campaigns', () => {
      it('deploys a factory and a campaign', () => {
          assert.ok(factory.options.address);
          assert.ok(campaign.options.address);
      });
  
      it('marks caller as the campaign manager', async () => {
          const manager = await campaign.methods.manager().call();
          assert.equal(accounts[0], manager);
      });
  
      it('allows people to contribute money and marks them as approvers', async () => {
          await campaign.methods.contribute().send({
              from: accounts[1],
              value: '200',
              gas: 1000000
          });
  
          const hasContributed = await campaign.methods.approvers(accounts[1]).call();
          assert(hasContributed);
      });
  
      it('requires a minimum contribution', async () => {
          try {
              await campaign.methods.contribute().send({
                  value: '5',
                  from: accounts[1]
              });
              assert(false);
          } catch (error) {
              assert(error);
          }
      });
  
      it('allows a manager to create a payment request', async () => {
          await campaign.methods.createRequest(
              'Test', '100', accounts[1]
          ).send({
              from: accounts[0],
              gas: 4712388 // default value
          });
  
          const request = await campaign.methods.requests(0).call();
          assert.equal('Test', request.description);
      });
  });
  