Ownable.js 963 B

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