SimpleToken.test.js 1.1 KB

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