1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

add tests

This commit is contained in:
Alex 2020-03-30 14:57:14 +03:00
parent 9b04e9e413
commit e04ecaf968

View File

@ -1,7 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { getMetadata } from '../utils' import { getMetadata } from '../utils'
import { Ocean, Account } from '../../../src' // @oceanprotocol/squid import { Ocean, Account, EditableMetaData } from '../../../src' // @oceanprotocol/squid
describe('Asset Owners', () => { describe('Asset Owners', () => {
let ocean: Ocean let ocean: Ocean
@ -80,8 +80,8 @@ describe('Asset Owners', () => {
const { length: finalLength1 } = await ocean.assets.consumerAssets( const { length: finalLength1 } = await ocean.assets.consumerAssets(
account2.getId() account2.getId()
) )
assert.equal(finalLength1 - initialLength, 0) assert.equal(finalLength1 - initialLength, 0)
// Granting access // Granting access
try { try {
await account2.requestTokens( await account2.requestTokens(
@ -92,7 +92,7 @@ describe('Asset Owners', () => {
).toString() ).toString()
) )
) )
} catch {} } catch { }
await ocean.assets.order(ddo.id, account2) await ocean.assets.order(ddo.id, account2)
// Access granted // Access granted
const { length: finalLength2 } = await ocean.assets.consumerAssets( const { length: finalLength2 } = await ocean.assets.consumerAssets(
@ -111,4 +111,27 @@ describe('Asset Owners', () => {
const aquariusOwner = await ocean.assets.owner(id) const aquariusOwner = await ocean.assets.owner(id)
assert.equal(aquariusOwner, account2.getId()) assert.equal(aquariusOwner, account2.getId())
}) })
it('should be able to update metadata', async () => {
const { id } = await ocean.assets.create(metadata as any, account1)
let newMetaData = {title: "New title", description: "New description"};
await ocean.assets.editMetadata(id,newMetaData,account1)
const newDDO = await ocean.assets.resolve(id)
assert.equal(newDDO['service'][0]['attributes']['main']['name'], "New title")
assert.equal(newDDO['service'][0]['attributes']['additionalInformation']['description'], "New description")
})
it('should be able to retire metadata', async () => {
const { id } = await ocean.assets.create(metadata as any, account1)
await ocean.assets.retire(id,account1)
const newDDO = await ocean.assets.resolve(id)
assert.equal(newDDO, null)
})
}) })