SimpleToken.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const expectEvent = require('../helpers/expectEvent');
  2. const { ZERO_ADDRESS } = require('../helpers/constants');
  3. const SimpleToken = artifacts.require('SimpleToken');
  4. const BigNumber = web3.BigNumber;
  5. require('chai')
  6. .use(require('chai-bignumber')(BigNumber))
  7. .should();
  8. contract('SimpleToken', function ([_, creator]) {
  9. beforeEach(async function () {
  10. this.token = await SimpleToken.new({ from: creator });
  11. });
  12. it('has a name', async function () {
  13. (await this.token.name()).should.equal('SimpleToken');
  14. });
  15. it('has a symbol', async function () {
  16. (await this.token.symbol()).should.equal('SIM');
  17. });
  18. it('has 18 decimals', async function () {
  19. (await this.token.decimals()).should.be.bignumber.equal(18);
  20. });
  21. it('assigns the initial total supply to the creator', async function () {
  22. const totalSupply = await this.token.totalSupply();
  23. const creatorBalance = await this.token.balanceOf(creator);
  24. creatorBalance.should.be.bignumber.equal(totalSupply);
  25. await expectEvent.inConstruction(this.token, 'Transfer', {
  26. from: ZERO_ADDRESS,
  27. to: creator,
  28. value: totalSupply,
  29. });
  30. });
  31. });