make claimable use fresh instances for each test

pull/67/head
Steve Ellis 8 years ago
parent 1547000d1c
commit a156064b33
  1. 47
      test/Claimable.js

@ -1,7 +1,13 @@
contract('Claimable', function(accounts) {
var claimable;
beforeEach(function() {
return Claimable.new().then(function(deployed) {
claimable = deployed;
});
});
it("should have an owner", function(done) {
var claimable = Claimable.deployed();
return claimable.owner()
.then(function(owner) {
assert.isTrue(owner != 0);
@ -10,19 +16,18 @@ contract('Claimable', function(accounts) {
});
it("changes pendingOwner after transfer", function(done) {
var claimable = Claimable.deployed();
return claimable.transfer(accounts[1])
var newOwner = accounts[1];
return claimable.transfer(newOwner)
.then(function() {
return claimable.pendingOwner();
})
.then(function(pendingOwner) {
assert.isTrue(pendingOwner === accounts[1]);
assert.isTrue(pendingOwner === newOwner);
})
.then(done)
});
it("should prevent to claimOwnership from no pendingOwner", function(done) {
var claimable = Claimable.deployed();
return claimable.claimOwnership({from: accounts[2]})
.then(function() {
return claimable.owner();
@ -33,20 +38,7 @@ contract('Claimable', function(accounts) {
.then(done)
});
it("changes allow pending owner to claim ownership", function(done) {
var claimable = Claimable.deployed();
return claimable.claimOwnership({from: accounts[1]})
.then(function() {
return claimable.owner();
})
.then(function(owner) {
assert.isTrue(owner === accounts[1]);
})
.then(done)
});
it("should prevent non-owners from transfering" ,function(done) {
var claimable = Claimable.deployed();
return claimable.transfer(accounts[2], {from: accounts[2]})
.then(function() {
return claimable.pendingOwner();
@ -57,4 +49,23 @@ contract('Claimable', function(accounts) {
.then(done)
});
describe("after initiating a transfer", function () {
var newOwner;
beforeEach(function () {
newOwner = accounts[1];
return claimable.transfer(newOwner);
});
it("changes allow pending owner to claim ownership", function(done) {
return claimable.claimOwnership({from: newOwner})
.then(function() {
return claimable.owner();
})
.then(function(owner) {
assert.isTrue(owner === newOwner);
})
.then(done)
});
});
});

Loading…
Cancel
Save