Created
April 8, 2019 20:44
-
-
Save Maxcutex/eb09ec1f8e7453b2f4d28f860af0a632 to your computer and use it in GitHub Desktop.
Election Testing File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Election = artifacts.require("./Election.sol"); | |
contract("Election", function(accounts) { | |
var electionInstance; | |
it("initializes with two candidates", function() { | |
return Election.deployed().then(function(instance) { | |
return instance.candidatesCount(); | |
}).then(function(count) { | |
assert.equal(count, 2); | |
}); | |
}); | |
it("it initializes the candidates with the correct values", function() { | |
return Election.deployed().then(function(instance) { | |
electionInstance = instance; | |
return electionInstance.candidates(1); | |
}).then(function(candidate) { | |
assert.equal(candidate[0], 1, "contains the correct id"); | |
assert.equal(candidate[1], "Candidate 1", "contains the correct name"); | |
assert.equal(candidate[2], 0, "contains the correct votes count"); | |
return electionInstance.candidates(2); | |
}).then(function(candidate) { | |
assert.equal(candidate[0], 2, "contains the correct id"); | |
assert.equal(candidate[1], "Candidate 2", "contains the correct name"); | |
assert.equal(candidate[2], 0, "contains the correct votes count"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment