Math.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const MathMock = artifacts.require('MathMock');
  2. const BigNumber = web3.BigNumber;
  3. require('chai')
  4. .use(require('chai-bignumber')(BigNumber))
  5. .should();
  6. contract('Math', function () {
  7. const min = 1234;
  8. const max = 5678;
  9. beforeEach(async function () {
  10. this.math = await MathMock.new();
  11. });
  12. describe('max', function () {
  13. it('is correctly detected in first argument position', async function () {
  14. const result = await this.math.max(max, min);
  15. result.should.be.bignumber.equal(max);
  16. });
  17. it('is correctly detected in second argument position', async function () {
  18. const result = await this.math.max(min, max);
  19. result.should.be.bignumber.equal(max);
  20. });
  21. });
  22. describe('min', function () {
  23. it('is correctly detected in first argument position', async function () {
  24. const result = await this.math.min(min, max);
  25. result.should.be.bignumber.equal(min);
  26. });
  27. it('is correctly detected in second argument position', async function () {
  28. const result = await this.math.min(max, min);
  29. result.should.be.bignumber.equal(min);
  30. });
  31. });
  32. });