fix: made code cleaner. added helper. removed done from most tests.

This commit is contained in:
Angello Pozo
2016-12-01 08:42:05 -08:00
parent 688106e9c3
commit eb41a81faa
11 changed files with 116 additions and 127 deletions

View File

@ -1,40 +1,38 @@
contract('Ownable', function(accounts) {
let ownable;
beforeEach(async function(done) {
beforeEach(async function() {
ownable = await Ownable.new();
done();
});
it("should have an owner", async function(done) {
it("should have an owner", async function() {
let owner = await ownable.owner();
assert.isTrue(owner != 0);
done();
});
it("changes owner after transfer", async function(done) {
it("changes owner after transfer", async function() {
let other = accounts[1];
let transfer = await ownable.transfer(other);
let owner = await ownable.owner();
assert.isTrue(owner === other);
done();
});
it("should prevent non-owners from transfering", async function(done) {
it("should prevent non-owners from transfering", async function() {
let other = accounts[2];
let transfer = await ownable.transfer(other, {from: accounts[2]});
let owner = await ownable.owner();
assert.isFalse(owner === other);
done();
});
it("should guard ownership against stuck state", async function(done) {
it("should guard ownership against stuck state", async function() {
let ownable = Ownable.deployed();
let originalOwner = await ownable.owner();
let transfer = await ownable.transfer(null, {from: originalOwner});
let newOwner = await ownable.owner();
assert.equal(originalOwner, newOwner);
done();
});
});