SimpleToken.test.js 1.2 KB

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