ERC6909Metadata.test.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const { ethers } = require('hardhat');
  2. const { expect } = require('chai');
  3. const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
  4. async function fixture() {
  5. const token = await ethers.deployContract('$ERC6909Metadata');
  6. return { token };
  7. }
  8. describe('ERC6909Metadata', function () {
  9. beforeEach(async function () {
  10. Object.assign(this, await loadFixture(fixture));
  11. });
  12. describe('name', function () {
  13. it('is empty string be default', async function () {
  14. await expect(this.token.name(1n)).to.eventually.equal('');
  15. });
  16. it('can be set by dedicated setter', async function () {
  17. await expect(this.token.$_setName(1n, 'My Token'))
  18. .to.emit(this.token, 'ERC6909NameUpdated')
  19. .withArgs(1n, 'My Token');
  20. await expect(this.token.name(1n)).to.eventually.equal('My Token');
  21. // Only set for the specified token ID
  22. await expect(this.token.name(2n)).to.eventually.equal('');
  23. });
  24. });
  25. describe('symbol', function () {
  26. it('is empty string be default', async function () {
  27. await expect(this.token.symbol(1n)).to.eventually.equal('');
  28. });
  29. it('can be set by dedicated setter', async function () {
  30. await expect(this.token.$_setSymbol(1n, 'MTK')).to.emit(this.token, 'ERC6909SymbolUpdated').withArgs(1n, 'MTK');
  31. await expect(this.token.symbol(1n)).to.eventually.equal('MTK');
  32. // Only set for the specified token ID
  33. await expect(this.token.symbol(2n)).to.eventually.equal('');
  34. });
  35. });
  36. describe('decimals', function () {
  37. it('is 0 by default', async function () {
  38. await expect(this.token.decimals(1n)).to.eventually.equal(0);
  39. });
  40. it('can be set by dedicated setter', async function () {
  41. await expect(this.token.$_setDecimals(1n, 18)).to.emit(this.token, 'ERC6909DecimalsUpdated').withArgs(1n, 18);
  42. await expect(this.token.decimals(1n)).to.eventually.equal(18);
  43. // Only set for the specified token ID
  44. await expect(this.token.decimals(2n)).to.eventually.equal(0);
  45. });
  46. });
  47. });