1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

DDO updates

This commit is contained in:
Matthias Kretschmann 2019-12-10 00:58:06 +01:00
parent affdcd48df
commit 645f3c0e13
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 40 additions and 6 deletions

View File

@ -0,0 +1,28 @@
import React from 'react'
import { render } from '@testing-library/react'
import Results from './Results'
import { User } from '../../context'
import { userMockConnected } from '../../../__mocks__/user-mock'
import {
results,
totalResults,
totalPages,
currentPage
} from '../../../__fixtures__/search.json'
describe('Results', () => {
it('renders without crashing', () => {
const { container } = render(
<User.Provider value={userMockConnected}>
<Results
results={results}
totalResults={totalResults}
totalPages={totalPages}
currentPage={currentPage}
handlePageClick={jest.fn()}
/>
</User.Provider>
)
expect(container.firstChild).toBeInTheDocument()
})
})

View File

@ -1,6 +1,7 @@
import React from 'react'
import { Link } from 'react-router-dom'
import shortid from 'shortid'
import { DDO } from '@oceanprotocol/squid'
import AssetTeaser from '../../components/molecules/AssetTeaser'
import Pagination from '../../components/molecules/Pagination'
import styles from './Results.module.scss'
@ -12,7 +13,7 @@ export default function Results({
currentPage,
handlePageClick
}: {
results: any[]
results: DDO[]
totalResults: number
totalPages: number
currentPage: number

View File

@ -25,10 +25,15 @@ function getFilterMetadata(results: any[]) {
results.map((asset: DDO) => {
if (!asset.findServiceByType) return null
const { metadata } = asset.findServiceByType('Metadata')
const { categories, license } = metadata.base
const { attributes } = asset.findServiceByType('metadata')
const { main, additionalInformation } = attributes
main.license && filterLicenses.push(main.license)
if (additionalInformation) {
const { categories } = additionalInformation
categories && filterCategories.push(categories[0])
license && filterLicenses.push(license)
}
return null
})

View File

@ -19,7 +19,7 @@ interface SearchProps {
}
interface SearchState {
results: any[]
results: DDO[]
totalResults: number
offset: number
totalPages: number