1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge pull request #116 from oceanprotocol/fix/unit-test

Fix/unit test
This commit is contained in:
Ahmed Ali 2020-07-02 17:10:06 +02:00 committed by GitHub
commit 5ee4b1e8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ describe('DataTokens', () => {
const blob = 'https://example.com/dataset-1' const blob = 'https://example.com/dataset-1'
describe('#test', () => { describe('#test', () => {
it('#deploy', async () => { it('should deploy contracts', async () => {
contracts = new TestContractHandler( contracts = new TestContractHandler(
factory.abi, factory.abi,
datatokensTemplate.abi, datatokensTemplate.abi,
@ -33,7 +33,7 @@ describe('DataTokens', () => {
await contracts.deployContracts(minter) await contracts.deployContracts(minter)
}) })
it('#init', async () => { it('should initialize datatokens class', async () => {
datatoken = new DataTokens( datatoken = new DataTokens(
contracts.factoryAddress, contracts.factoryAddress,
factory.abi, factory.abi,
@ -43,30 +43,30 @@ describe('DataTokens', () => {
assert(datatoken !== null) assert(datatoken !== null)
}) })
it('#create', async () => { it('should create datatokens smart contract', async () => {
tokenAddress = await datatoken.create(blob, minter) tokenAddress = await datatoken.create(blob, minter)
assert(tokenAddress !== null) assert(tokenAddress !== null)
}) })
it('#mint', async () => { it('should mint datatokens', async () => {
await datatoken.mint(tokenAddress, minter, tokenAmount) await datatoken.mint(tokenAddress, minter, tokenAmount)
balance = await datatoken.balance(tokenAddress, minter) balance = await datatoken.balance(tokenAddress, minter)
assert(balance.toString() === tokenAmount.toString()) assert(balance.toString() === tokenAmount.toString())
}) })
it('#transfer', async () => { it('should transfer datatokens', async () => {
await datatoken.transfer(tokenAddress, spender, tokenAmount, minter) await datatoken.transfer(tokenAddress, spender, tokenAmount, minter)
balance = await datatoken.balance(tokenAddress, spender) balance = await datatoken.balance(tokenAddress, spender)
assert(balance.toString() === tokenAmount.toString()) assert(balance.toString() === tokenAmount.toString())
}) })
it('#approve', async () => { it('should approve datatokens transfer', async () => {
await datatoken.approve(tokenAddress, minter, tokenAmount, spender) await datatoken.approve(tokenAddress, minter, tokenAmount, spender)
}) })
it('#transferFrom', async () => { it('should transferFrom datatokens', async () => {
await datatoken.transferFrom(tokenAddress, spender, tokenAmount, minter) await datatoken.transferFrom(tokenAddress, spender, tokenAmount, minter)
minter = await datatoken.balance(tokenAddress, spender) balance = await datatoken.balance(tokenAddress, minter)
assert(balance.toString() === tokenAmount.toString()) assert(balance.toString() === tokenAmount.toString())
}) })
}) })