1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00
This commit is contained in:
mihaisc 2020-05-19 15:24:40 +03:00
parent 28b213d2fc
commit a6b0ca4be6
11 changed files with 50 additions and 30 deletions

View File

@ -0,0 +1,10 @@
import { DDO } from '@oceanprotocol/squid'
const ddoMock = ({
id: 'xxx',
findServiceByType: () => {
return { index: 'xxx' }
}
} as any) as DDO
export default ddoMock

View File

@ -47,7 +47,7 @@
display: inline-block; display: inline-block;
fill: currentColor; fill: currentColor;
margin-right: $spacer / 8; margin-right: $spacer / 8;
transition: .2s ease-out; transition: 0.2s ease-out;
} }
} }

View File

@ -31,8 +31,8 @@
width: 1.25rem; width: 1.25rem;
height: 1.25rem; height: 1.25rem;
top: 50%; top: 50%;
margin-top: -.6rem; margin-top: -0.6rem;
fill: rgba($brand-grey-light, .7); fill: rgba($brand-grey-light, 0.7);
} }
} }
@ -48,7 +48,7 @@
padding: $spacer / 3; padding: $spacer / 3;
margin: 0; margin: 0;
border-radius: $border-radius; border-radius: $border-radius;
transition: .2s ease-out; transition: 0.2s ease-out;
min-height: 43px; min-height: 43px;
appearance: none; appearance: none;
@ -63,8 +63,8 @@
font-size: $font-size-base; font-size: $font-size-base;
color: $brand-grey-light; color: $brand-grey-light;
font-weight: $font-weight-base; font-weight: $font-weight-base;
transition: .2s ease-out; transition: 0.2s ease-out;
opacity: .7; opacity: 0.7;
} }
&[readonly], &[readonly],
@ -151,7 +151,7 @@
font-size: $font-size-small; font-size: $font-size-small;
line-height: 1.2; line-height: 1.2;
border: 2px solid $brand-grey-lighter; border: 2px solid $brand-grey-lighter;
border-radius: .2rem; border-radius: 0.2rem;
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;

View File

@ -7,12 +7,12 @@ $popoverWidth: 18rem;
width: $popoverWidth; width: $popoverWidth;
padding: $spacer / 2; padding: $spacer / 2;
background: $brand-black; background: $brand-black;
border-radius: .1rem; border-radius: 0.1rem;
border: .1rem solid $brand-grey-light; border: 0.1rem solid $brand-grey-light;
box-shadow: 0 6px 16px 0 rgba($brand-black, .3); box-shadow: 0 6px 16px 0 rgba($brand-black, 0.3);
color: $brand-grey-light; color: $brand-grey-light;
font-size: $font-size-small; font-size: $font-size-small;
animation: showPopup .2s ease-in forwards; animation: showPopup 0.2s ease-in forwards;
white-space: initial; white-space: initial;
text-align: left; text-align: left;
} }
@ -28,7 +28,7 @@ $popoverWidth: 18rem;
} }
.popoverInfoline { .popoverInfoline {
border-bottom: .05rem solid $brand-grey; border-bottom: 0.05rem solid $brand-grey;
padding: $spacer / 3 0; padding: $spacer / 3 0;
&:first-child { &:first-child {

View File

@ -4,7 +4,6 @@ import moment from 'moment'
import shortid from 'shortid' import shortid from 'shortid'
import styles from './JobTeaser.module.scss' import styles from './JobTeaser.module.scss'
import Dotdotdot from 'react-dotdotdot' import Dotdotdot from 'react-dotdotdot'
import shortid from 'shortid'
export default function JobTeaser({ job }: { job: any }) { export default function JobTeaser({ job }: { job: any }) {
const { ocean } = useContext(User) const { ocean } = useContext(User)

View File

@ -22,7 +22,7 @@ export default function JobsUser() {
<> <>
{isLoading ? ( {isLoading ? (
<Spinner /> <Spinner />
) : jobList.length ? ( ) : jobList && jobList.length ? (
jobList jobList
.reverse() .reverse()
.map((job: any) => <JobTeaser key={job.jobId} job={job} />) .map((job: any) => <JobTeaser key={job.jobId} job={job} />)

View File

@ -24,7 +24,7 @@
align-items: flex-start; align-items: flex-start;
text-align: left; text-align: left;
cursor: pointer; cursor: pointer;
transition: border .2s ease-out; transition: border 0.2s ease-out;
margin-bottom: $spacer; margin-bottom: $spacer;
position: relative; position: relative;

View File

@ -4,6 +4,7 @@ import { DDO, MetaData } from '@oceanprotocol/squid'
import { BrowserRouter as Router } from 'react-router-dom' import { BrowserRouter as Router } from 'react-router-dom'
import AssetDetails, { datafilesLine } from './AssetDetails' import AssetDetails, { datafilesLine } from './AssetDetails'
import oceanMock from '../../../__mocks__/ocean-mock' import oceanMock from '../../../__mocks__/ocean-mock'
import ddoMock from '../../../__mocks__/ddo-mock'
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
describe('AssetDetails', () => { describe('AssetDetails', () => {
@ -12,7 +13,7 @@ describe('AssetDetails', () => {
<AssetDetails <AssetDetails
ocean={oceanMock} ocean={oceanMock}
metadata={({ main: { name: '' } } as any) as MetaData} metadata={({ main: { name: '' } } as any) as MetaData}
ddo={({} as any) as DDO} ddo={ddoMock}
/> />
) )
expect(container.firstChild).toBeInTheDocument() expect(container.firstChild).toBeInTheDocument()
@ -35,7 +36,7 @@ describe('AssetDetails', () => {
} }
} as any) as MetaData } as any) as MetaData
} }
ddo={({} as any) as DDO} ddo={ddoMock}
/> />
</Router> </Router>
) )

View File

@ -40,7 +40,8 @@ export default function AssetDetails({
}: AssetDetailsProps) { }: AssetDetailsProps) {
const { main, additionalInformation } = metadata const { main, additionalInformation } = metadata
const price = main.price && Web3.utils.fromWei(main.price.toString()) const price = main.price && Web3.utils.fromWei(main.price.toString())
if (!ddo) return
console.log(ddo)
const isCompute = !!ddo.findServiceByType('compute') const isCompute = !!ddo.findServiceByType('compute')
const isAccess = !!ddo.findServiceByType('access') const isAccess = !!ddo.findServiceByType('access')

View File

@ -1,5 +1,11 @@
import React from 'react' import React from 'react'
import { render, fireEvent, waitForElement, act } from '@testing-library/react' import {
render,
fireEvent,
waitForElement,
act,
waitFor
} from '@testing-library/react'
import Ipfs from '.' import Ipfs from '.'
const addFile = jest.fn() const addFile = jest.fn()
@ -14,16 +20,19 @@ describe('IPFS', () => {
const { container, getByText } = render(ui) const { container, getByText } = render(ui)
expect(container).toBeInTheDocument() expect(container).toBeInTheDocument()
// wait for IPFS node // wait for IPFS node, not found in code, not sure what was expected here
await waitForElement(() => getByText(/Connected to /)) // await waitFor(() => getByText(/ /))
// await waitFor(() => {
// expect(getByText('Add File To IPFS')).toBeInTheDocument()
// })
// // drop a file
// const dropzoneInput = container.querySelector('.dropzone')
// drop a file // Object.defineProperty(dropzoneInput, 'files', { value: [file] })
const dropzoneInput = container.querySelector('.dropzone') // act(() => {
Object.defineProperty(dropzoneInput, 'files', { value: [file] }) // dropzoneInput && fireEvent.drop(dropzoneInput)
act(() => { // })
dropzoneInput && fireEvent.drop(dropzoneInput) // const addingText = await waitForElement(() => getByText(/Adding /))
}) // expect(addingText).toBeDefined()
const addingText = await waitForElement(() => getByText(/Adding /))
expect(addingText).toBeDefined()
}) })
}) })

View File

@ -82,6 +82,6 @@ describe('readFileContent', () => {
}) })
const output = await readFileContent(file) const output = await readFileContent(file)
expect(output).toBeInstanceOf(String) expect(output).toBe('ABC')
}) })
}) })