mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add more NFTFactory test
This commit is contained in:
parent
3c638ab597
commit
2bd5d55198
@ -130,7 +130,7 @@ export class NFTFactory {
|
||||
* @return {Promise<number>} Number of ERC20 Template added to this factory
|
||||
*/
|
||||
public async getCurrentTokenTemplateCount(): Promise<number> {
|
||||
const count = await this.factory721.methods.getCurrentTokenTemplateCount().call()
|
||||
const count = await this.factory721.methods.getCurrentTemplateCount().call()
|
||||
return count
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,86 @@ describe('NFT Factory test', () => {
|
||||
|
||||
it('should initiate NFTFactory instance', async () => {
|
||||
nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance)
|
||||
})
|
||||
|
||||
it('#getCurrentNFTCount - should return actual nft count (0)', async () => {
|
||||
const nftCount = await nftFactory.getCurrentNFTCount()
|
||||
assert(nftCount == 0)
|
||||
})
|
||||
|
||||
it('#getCurrentTokenCount - should return actual token count (0)', async () => {
|
||||
const tokenCount = await nftFactory.getCurrentTokenCount()
|
||||
assert(tokenCount == 0)
|
||||
})
|
||||
it('#getOwner - should return actual owner', async () => {
|
||||
const owner = await nftFactory.getOwner()
|
||||
assert(owner === contracts.accounts[0])
|
||||
})
|
||||
it('#getCurrentNFTTemplateCount - should return actual nft template count (1)', async () => {
|
||||
const nftTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
assert(nftTemplateCount == 1)
|
||||
})
|
||||
it('#getCurrentTokenTemplateCount - should return actual token template count (1)', async () => {
|
||||
const tokenTemplateCount = await nftFactory.getCurrentTokenTemplateCount()
|
||||
assert(tokenTemplateCount == 1)
|
||||
})
|
||||
it('#getNFTTemplate - should return NFT template struct', async () => {
|
||||
const nftTemplate = await nftFactory.getNFTTemplate(1)
|
||||
assert(nftTemplate.isActive === true)
|
||||
assert(nftTemplate.templateAddress === contracts.template721Address)
|
||||
})
|
||||
it('#getTokenTemplate - should return Token template struct', async () => {
|
||||
const tokenTemplate = await nftFactory.getTokenTemplate(1)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
assert(tokenTemplate.templateAddress === contracts.template20Address)
|
||||
})
|
||||
it('#addNFTTemplate - should add NFT template if factory owner', async () => {
|
||||
await nftFactory.addNFTTemplate(contracts.accounts[0], contracts.fixedRateAddress) // contracts.fixedRateAddress it's just a dummy contract in this case
|
||||
const nftTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
assert(nftTemplateCount == 2)
|
||||
const nftTemplate = await nftFactory.getNFTTemplate(2)
|
||||
assert(nftTemplate.isActive === true)
|
||||
assert(nftTemplate.templateAddress === contracts.fixedRateAddress)
|
||||
})
|
||||
it('#disableNFTTemplate - should disable NFT template if factory owner', async () => {
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(2)
|
||||
assert(nftTemplate.isActive === true)
|
||||
await nftFactory.disableNFTTemplate(contracts.accounts[0], 2) // owner disable template index = 2
|
||||
|
||||
nftTemplate = await nftFactory.getNFTTemplate(2)
|
||||
assert(nftTemplate.isActive === false)
|
||||
})
|
||||
it('#reactivateNFTTemplate - should disable NFT template if factory owner', async () => {
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(2)
|
||||
assert(nftTemplate.isActive === false)
|
||||
await nftFactory.reactivateNFTTemplate(contracts.accounts[0], 2) // owner reactivate template index = 2
|
||||
|
||||
nftTemplate = await nftFactory.getNFTTemplate(2)
|
||||
assert(nftTemplate.isActive === true)
|
||||
})
|
||||
it('#addTokenTemplate - should add Datatoken template if factory owner', async () => {
|
||||
await nftFactory.addTokenTemplate(contracts.accounts[0], contracts.fixedRateAddress) // contracts.fixedRateAddress it's just a dummy contract in this case
|
||||
const tokenTemplateCount = await nftFactory.getCurrentTokenTemplateCount()
|
||||
assert(tokenTemplateCount == 2)
|
||||
const nftTemplate = await nftFactory.getTokenTemplate(2)
|
||||
assert(nftTemplate.isActive === true)
|
||||
assert(nftTemplate.templateAddress === contracts.fixedRateAddress)
|
||||
})
|
||||
|
||||
it('#disableTokenTemplate - should disable Token template if factory owner', async () => {
|
||||
let tokenTemplate = await nftFactory.getTokenTemplate(2)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
await nftFactory.disableTokenTemplate(contracts.accounts[0], 2) // owner disable template index = 2
|
||||
|
||||
tokenTemplate = await nftFactory.getTokenTemplate(2)
|
||||
assert(tokenTemplate.isActive === false)
|
||||
})
|
||||
it('#reactivateTokenTemplate - should disable Token template if factory owner', async () => {
|
||||
let tokenTemplate = await nftFactory.getTokenTemplate(2)
|
||||
assert(tokenTemplate.isActive === false)
|
||||
await nftFactory.reactivateTokenTemplate(contracts.accounts[0], 2) // owner reactivate template index = 2
|
||||
|
||||
tokenTemplate = await nftFactory.getTokenTemplate(2)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user