Strings.test.js 810 B

1234567891011121314151617181920212223242526
  1. const { contract } = require('@openzeppelin/test-environment');
  2. const { constants } = require('@openzeppelin/test-helpers');
  3. const { expect } = require('chai');
  4. const StringsMock = contract.fromArtifact('StringsMock');
  5. describe('Strings', function () {
  6. beforeEach(async function () {
  7. this.strings = await StringsMock.new();
  8. });
  9. describe('from uint256', function () {
  10. it('converts 0', async function () {
  11. expect(await this.strings.fromUint256(0)).to.equal('0');
  12. });
  13. it('converts a positive number', async function () {
  14. expect(await this.strings.fromUint256(4132)).to.equal('4132');
  15. });
  16. it('converts MAX_UINT256', async function () {
  17. expect(await this.strings.fromUint256(constants.MAX_UINT256)).to.equal(constants.MAX_UINT256.toString());
  18. });
  19. });
  20. });