Skip to content

Instantly share code, notes, and snippets.

@adrianmcli
Last active July 13, 2018 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianmcli/b57c12c65c201faf5b41bd525b4fe5fe to your computer and use it in GitHub Desktop.
Save adrianmcli/b57c12c65c201faf5b41bd525b4fe5fe to your computer and use it in GitHub Desktop.
const Counter = artifacts.require("Counter")
contract("Counter", (accounts) => {
it("should initialize with a count of 0", async () => {
const counter = await Counter.deployed()
const count = await counter.get.call()
const expected = 0
assert.equal(count, expected, "count was not initialized with 0")
})
it("should increment to a count of 1", async () => {
const counter = await Counter.deployed()
await counter.increment({ from: accounts[0] })
const count = await counter.get.call()
const expected = 1
assert.equal(count, expected, "count was not incremented to 1")
})
it("should decrement back to a count of 0", async () => {
const counter = await Counter.deployed()
await counter.decrement({ from: accounts[0] })
const count = await counter.get.call()
const expected = 0
assert.equal(count, expected, "count was not decremented back to 0")
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment