ownable.js 907 B

12345678910111213141516171819202122232425262728293031323334353637
  1. contract('Ownable', function(accounts) {
  2. it("should have an owner", function(done) {
  3. var ownable = Ownable.deployed();
  4. return ownable.owner()
  5. .then(function(owner) {
  6. assert.isTrue(owner != 0);
  7. })
  8. .then(done)
  9. });
  10. it("changes owner after transfer", function(done) {
  11. var ownable = Ownable.deployed();
  12. var other = accounts[1];
  13. return ownable.transfer(other)
  14. .then(function() {
  15. return ownable.owner();
  16. })
  17. .then(function(owner) {
  18. assert.isTrue(owner === other);
  19. })
  20. .then(done)
  21. });
  22. it("should prevent non-owners from transfering" ,function(done) {
  23. var ownable = Ownable.deployed();
  24. var other = accounts[2];
  25. return ownable.transfer(other, {from: accounts[2]})
  26. .then(function() {
  27. return ownable.owner();
  28. })
  29. .then(function(owner) {
  30. assert.isFalse(owner === other);
  31. })
  32. .then(done)
  33. });
  34. });