From e04ecaf968c65b10e64c4d432399f2197fee879d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Mar 2020 14:57:14 +0300 Subject: [PATCH] add tests --- test/integration/ocean/AssetOwners.test.ts | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/test/integration/ocean/AssetOwners.test.ts b/test/integration/ocean/AssetOwners.test.ts index e20d739..7e616d0 100644 --- a/test/integration/ocean/AssetOwners.test.ts +++ b/test/integration/ocean/AssetOwners.test.ts @@ -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) + + }) })