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

remove asset sample link if not send on metadata update

This commit is contained in:
Bogdan Fazakas 2021-02-08 16:46:22 +02:00
parent c417fc4399
commit 3608472e75
2 changed files with 23 additions and 1 deletions

View File

@ -260,8 +260,11 @@ export class Assets extends Instantiable {
if (newMetadata.description)
ddo.service[i].attributes.additionalInformation.description =
newMetadata.description
if (newMetadata.links)
if (newMetadata.links) {
ddo.service[i].attributes.additionalInformation.links = newMetadata.links
} else {
ddo.service[i].attributes.additionalInformation.links = []
}
}
return ddo
}

View File

@ -226,6 +226,25 @@ describe('Marketplace flow', () => {
assert.deepEqual(metaData.attributes.additionalInformation.links, newMetaData.links)
})
it('Alice updates metadata and removes sample links', async () => {
const newMetaData: EditableMetadata = {
description: 'new description no links',
title: 'new title no links'
}
const newDdo = await ocean.assets.editMetadata(ddo, newMetaData)
assert(newDdo !== null)
const txid = await ocean.onChainMetadata.update(newDdo.id, newDdo, alice.getId())
assert(txid !== null)
await sleep(60000)
const metaData = await ocean.assets.getServiceByType(ddo.id, 'metadata')
assert.equal(metaData.attributes.main.name, newMetaData.title)
assert.equal(
metaData.attributes.additionalInformation.description,
newMetaData.description
)
assert.deepEqual(metaData.attributes.additionalInformation.links, [])
})
it('Alice updates timeout for the access service', async () => {
const service = ddo.findServiceByType('access')
assert(service !== null)