Skip to content

Instantly share code, notes, and snippets.

@mseijas
Last active May 23, 2018 19:33
Show Gist options
  • Save mseijas/c485eeae21aeee0c36a454ec25d74d2e to your computer and use it in GitHub Desktop.
Save mseijas/c485eeae21aeee0c36a454ec25d74d2e to your computer and use it in GitHub Desktop.
const SocialNetworkProxy = artifacts.require('SocialNetworkProxy')
const SocialNetworkV1 = artifacts.require('SocialNetworkV1')
contract('SocialNetworkProxy', async () => {
let proxy, socialNetworkProxy, socialNetworkV1
before(async () => {
proxy = await SocialNetworkProxy.deployed()
socialNetworkProxy = SocialNetworkV1.at(proxy.address)
socialNetworkV1 = await SocialNetworkV1.deployed()
})
it('should have the SocialNetworkV1 address as its implementation', async () => {
const implementation = await proxy.implementation()
expect(implementation).to.equal(socialNetworkV1.address)
})
context('when delegating to the SocialNetworkV1 contract', async () => {
before(async () => {
socialNetworkProxy = SocialNetworkV1.at(proxy.address)
})
it('should return a name', async () => {
const name = await socialNetworkProxy.name()
expect(name).to.equal('TanookiChats')
})
it('should throw when setting a name with less than 3 characters', async () => {
try {
await socialNetworkProxy.setName('HI')
} catch (error) {
expect(error).not.to.equal(null)
}
})
it('should return an imageUrl', async () => {
const imageUrl = await socialNetworkProxy.imageUrl()
expect(imageUrl).to.equal('http://tanookilabs.com/images/tanooki-small@2x-0500fc1e.png')
})
it('sould allow us to update the imageUrl', async () => {
await socialNetworkProxy.setImageUrl('http://tanookilabs.com/images/exploding-beaker@2x-30aa1907.png')
const imageUrl = await socialNetworkProxy.imageUrl()
expect(imageUrl).to.equal('http://tanookilabs.com/images/exploding-beaker@2x-30aa1907.png')
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment