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:
parent
9b04e9e413
commit
e04ecaf968
@ -1,7 +1,7 @@
|
||||
import { assert } from 'chai'
|
||||
import { config } from '../config'
|
||||
import { getMetadata } from '../utils'
|
||||
import { Ocean, Account } from '../../../src' // @oceanprotocol/squid
|
||||
import { Ocean, Account, EditableMetaData } from '../../../src' // @oceanprotocol/squid
|
||||
|
||||
describe('Asset Owners', () => {
|
||||
let ocean: Ocean
|
||||
@ -80,8 +80,8 @@ describe('Asset Owners', () => {
|
||||
const { length: finalLength1 } = await ocean.assets.consumerAssets(
|
||||
account2.getId()
|
||||
)
|
||||
|
||||
assert.equal(finalLength1 - initialLength, 0)
|
||||
|
||||
// Granting access
|
||||
try {
|
||||
await account2.requestTokens(
|
||||
@ -92,7 +92,7 @@ describe('Asset Owners', () => {
|
||||
).toString()
|
||||
)
|
||||
)
|
||||
} catch {}
|
||||
} catch { }
|
||||
await ocean.assets.order(ddo.id, account2)
|
||||
// Access granted
|
||||
const { length: finalLength2 } = await ocean.assets.consumerAssets(
|
||||
@ -111,4 +111,27 @@ describe('Asset Owners', () => {
|
||||
const aquariusOwner = await ocean.assets.owner(id)
|
||||
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)
|
||||
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user