Claimable.test.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { assertRevert } = require('../helpers/assertRevert');
  2. const Claimable = artifacts.require('Claimable');
  3. const BigNumber = web3.BigNumber;
  4. require('chai')
  5. .use(require('chai-bignumber')(BigNumber))
  6. .should();
  7. contract('Claimable', function ([_, owner, newOwner, anyone]) {
  8. let claimable;
  9. beforeEach(async function () {
  10. claimable = await Claimable.new({ from: owner });
  11. });
  12. it('should have an owner', async function () {
  13. (await claimable.owner()).should.not.equal(0);
  14. });
  15. it('changes pendingOwner after transfer', async function () {
  16. await claimable.transferOwnership(newOwner, { from: owner });
  17. (await claimable.pendingOwner()).should.equal(newOwner);
  18. });
  19. it('should prevent to claimOwnership from anyone', async function () {
  20. await assertRevert(claimable.claimOwnership({ from: anyone }));
  21. });
  22. it('should prevent non-owners from transfering', async function () {
  23. await assertRevert(claimable.transferOwnership(anyone, { from: anyone }));
  24. });
  25. describe('after initiating a transfer', function () {
  26. beforeEach(async function () {
  27. await claimable.transferOwnership(newOwner, { from: owner });
  28. });
  29. it('changes allow pending owner to claim ownership', async function () {
  30. await claimable.claimOwnership({ from: newOwner });
  31. (await claimable.owner()).should.equal(newOwner);
  32. });
  33. });
  34. });