|
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/[email protected]') |
|
}) |
|
|
|
it('sould allow us to update the imageUrl', async () => { |
|
await socialNetworkProxy.setImageUrl('http://tanookilabs.com/images/[email protected]') |
|
|
|
const imageUrl = await socialNetworkProxy.imageUrl() |
|
expect(imageUrl).to.equal('http://tanookilabs.com/images/[email protected]') |
|
}) |
|
}) |
|
}) |