SimpleToken.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const { constants, expectEvent } = require('openzeppelin-test-helpers');
  2. const { ZERO_ADDRESS } = constants;
  3. const { expect } = require('chai');
  4. const SimpleToken = artifacts.require('SimpleToken');
  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. expect(await this.token.name()).to.equal('SimpleToken');
  11. });
  12. it('has a symbol', async function () {
  13. expect(await this.token.symbol()).to.equal('SIM');
  14. });
  15. it('has 18 decimals', async function () {
  16. expect(await this.token.decimals()).to.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. expect(creatorBalance).to.be.bignumber.equal(totalSupply);
  22. await expectEvent.inConstruction(this.token, 'Transfer', {
  23. from: ZERO_ADDRESS,
  24. to: creator,
  25. value: totalSupply,
  26. });
  27. });
  28. });