mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
DDO updates
This commit is contained in:
parent
affdcd48df
commit
645f3c0e13
28
client/src/routes/Search/Results.test.tsx
Normal file
28
client/src/routes/Search/Results.test.tsx
Normal 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()
|
||||
})
|
||||
})
|
@ -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
|
||||
|
@ -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
|
||||
categories && filterCategories.push(categories[0])
|
||||
license && filterLicenses.push(license)
|
||||
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])
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
|
||||
|
@ -19,7 +19,7 @@ interface SearchProps {
|
||||
}
|
||||
|
||||
interface SearchState {
|
||||
results: any[]
|
||||
results: DDO[]
|
||||
totalResults: number
|
||||
offset: number
|
||||
totalPages: number
|
||||
|
Loading…
Reference in New Issue
Block a user