mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 01:34:57 +01:00
more fixes
This commit is contained in:
parent
2b813dbaaa
commit
818a399a97
2
src/@types/Form.d.ts
vendored
2
src/@types/Form.d.ts
vendored
@ -12,7 +12,7 @@ export interface FormFieldProps {
|
|||||||
|
|
||||||
export interface FormContent {
|
export interface FormContent {
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description?: string
|
||||||
success: string
|
success: string
|
||||||
data: FormFieldProps[]
|
data: FormFieldProps[]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Center } from '../../../.storybook/helpers'
|
import { Center } from '../../../.storybook/helpers'
|
||||||
import { Alert } from './Alert'
|
import Alert from './Alert'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Atoms/Alert',
|
title: 'Atoms/Alert',
|
||||||
|
@ -12,7 +12,3 @@ export const Normal = () => <Loader />
|
|||||||
export const WithMessage = () => (
|
export const WithMessage = () => (
|
||||||
<Loader message="Crunching all the tech for you..." />
|
<Loader message="Crunching all the tech for you..." />
|
||||||
)
|
)
|
||||||
|
|
||||||
export const WithMessageHorizontal = () => (
|
|
||||||
<Loader message="Crunching all the tech for you..." isHorizontal />
|
|
||||||
)
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import Eye from '../../../images/eye.svg'
|
import Eye from '../../../images/eye.svg'
|
||||||
import Button from '../Button'
|
import Button from '../Button'
|
||||||
import Tooltip from '../Tooltip'
|
import Tooltip from '../Tooltip'
|
||||||
@ -10,7 +10,7 @@ export declare type ActionsCellProps = {
|
|||||||
|
|
||||||
export default function ActionsCell({
|
export default function ActionsCell({
|
||||||
handleOnClickViewJobDetails
|
handleOnClickViewJobDetails
|
||||||
}: ActionsCellProps) {
|
}: ActionsCellProps): ReactElement {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{handleOnClickViewJobDetails && (
|
{handleOnClickViewJobDetails && (
|
||||||
|
@ -7,4 +7,9 @@ export default {
|
|||||||
title: 'Molecules/Asset Teaser'
|
title: 'Molecules/Asset Teaser'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Default = () => <AssetTeaser ddo={new DDO(ddo)} />
|
export const Default = () => (
|
||||||
|
<AssetTeaser
|
||||||
|
did={ddo.id}
|
||||||
|
metadata={new DDO(ddo).findServiceByType('metadata').attributes as any}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import isUrl from 'is-url-superb'
|
import isUrl from 'is-url-superb'
|
||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import Input from '../../atoms/Input'
|
|
||||||
import { useField } from 'formik'
|
import { useField } from 'formik'
|
||||||
import Loader from '../../atoms/Loader'
|
import Loader from '../../atoms/Loader'
|
||||||
|
import InputElement from '../../atoms/Input/InputElement'
|
||||||
|
|
||||||
export default function FileInput({
|
export default function FileInput({
|
||||||
handleButtonClick,
|
handleButtonClick,
|
||||||
@ -17,7 +17,7 @@ export default function FileInput({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Input type="url" name="url" placeholder="e.g." {...field} />
|
<InputElement {...field} {...props} type="url" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
|
@ -42,6 +42,7 @@ export default function FilesInput(
|
|||||||
<FileInfo file={field.value[0]} removeItem={removeItem} />
|
<FileInfo file={field.value[0]} removeItem={removeItem} />
|
||||||
) : (
|
) : (
|
||||||
<FileInput
|
<FileInput
|
||||||
|
{...props}
|
||||||
{...field}
|
{...field}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
handleButtonClick={handleButtonClick}
|
handleButtonClick={handleButtonClick}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { PublishFormData } from '../../../src/models/PublishForm'
|
import { MetaDataPublishForm } from '../../../src/@types/MetaData'
|
||||||
|
|
||||||
const testFormData: PublishFormData = {
|
const testFormData: MetaDataPublishForm = {
|
||||||
author: '',
|
author: '',
|
||||||
files: [],
|
files: [],
|
||||||
license: '',
|
license: '',
|
||||||
@ -8,8 +8,8 @@ const testFormData: PublishFormData = {
|
|||||||
name: '',
|
name: '',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
termsAndConditions: true,
|
termsAndConditions: true,
|
||||||
access: 'Download',
|
access: 'Download'
|
||||||
links: []
|
// links: []
|
||||||
}
|
}
|
||||||
|
|
||||||
export default testFormData
|
export default testFormData
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { render, act } from '@testing-library/react'
|
|
||||||
import DateRangeWidget, {
|
|
||||||
getWidgetValue
|
|
||||||
} from '../../../src/components/atoms/FormWidgets/DateRangeWidget'
|
|
||||||
import { PublishFormSchema } from '../../../src/models/PublishForm'
|
|
||||||
|
|
||||||
describe('Date Range Widget', () => {
|
|
||||||
it('renders without crashing', () => {
|
|
||||||
act(() => {
|
|
||||||
const { container } = render(
|
|
||||||
<DateRangeWidget
|
|
||||||
schema={PublishFormSchema}
|
|
||||||
id="1"
|
|
||||||
autofocus={false}
|
|
||||||
disabled={false}
|
|
||||||
label="Date Range"
|
|
||||||
formContext={{}}
|
|
||||||
readonly={false}
|
|
||||||
value={'["2020-03-15T15:13:30Z", "2020-03-18T15:13:30Z"]'}
|
|
||||||
onBlur={() => {
|
|
||||||
/* */
|
|
||||||
}}
|
|
||||||
onFocus={() => {
|
|
||||||
/* */
|
|
||||||
}}
|
|
||||||
onChange={() => {
|
|
||||||
/* */
|
|
||||||
}}
|
|
||||||
options={{}}
|
|
||||||
required={false}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('getWidgetValue returns a correctly encoded string', () => {
|
|
||||||
expect(
|
|
||||||
getWidgetValue(
|
|
||||||
new Date('2020-03-15T15:13:30.123Z'),
|
|
||||||
new Date('2020-03-18T15:13:30.456Z'),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
).toEqual('["2020-03-15T15:13:30Z","2020-03-15T15:13:30Z"]')
|
|
||||||
|
|
||||||
expect(
|
|
||||||
getWidgetValue(
|
|
||||||
new Date('2020-03-15T15:13:30.123Z'),
|
|
||||||
new Date('2020-03-18T18:13:30.456Z'),
|
|
||||||
true
|
|
||||||
)
|
|
||||||
).toEqual('["2020-03-15T15:13:30Z","2020-03-18T18:13:30Z"]')
|
|
||||||
})
|
|
||||||
})
|
|
@ -12,7 +12,9 @@ describe('Layout', () => {
|
|||||||
|
|
||||||
testRender(
|
testRender(
|
||||||
<LocationProvider history={history}>
|
<LocationProvider history={history}>
|
||||||
<Layout location={{ href: 'https://demo.com' } as Location}>Hello</Layout>
|
<Layout title="Hello" uri={history.location.href}>
|
||||||
|
Hello
|
||||||
|
</Layout>
|
||||||
</LocationProvider>
|
</LocationProvider>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -1,80 +1,30 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { render } from '@testing-library/react'
|
import { render } from '@testing-library/react'
|
||||||
import Form, {
|
|
||||||
transformErrors
|
|
||||||
} from '../../../src/components/molecules/FilesInput'
|
|
||||||
import {
|
|
||||||
publishFormData,
|
|
||||||
PublishFormDataInterface,
|
|
||||||
PublishFormSchema,
|
|
||||||
PublishFormUiSchema
|
|
||||||
} from '../../../src/models/PublishForm'
|
|
||||||
import testFormData from '../__fixtures__/testFormData'
|
|
||||||
import { transformPublishFormToMetadata } from '../../../src/components/pages/Publish/utils'
|
import { transformPublishFormToMetadata } from '../../../src/components/pages/Publish/utils'
|
||||||
import { MetaDataMarket } from '../../../src/@types/MetaData'
|
import {
|
||||||
|
MetaDataMarket,
|
||||||
|
MetaDataPublishForm
|
||||||
|
} from '../../../src/@types/MetaData'
|
||||||
|
import PublishForm from '../../../src/components/pages/Publish/PublishForm'
|
||||||
|
import publishFormData from '../__fixtures__/testFormData'
|
||||||
|
import content from '../../../content/pages/publish.json'
|
||||||
|
|
||||||
describe('PublishForm', () => {
|
describe('PublishForm', () => {
|
||||||
it('renders without crashing', async () => {
|
it('renders without crashing', async () => {
|
||||||
const { container } = render(
|
const { container } = render(<PublishForm content={content.form} />)
|
||||||
<Form
|
|
||||||
schema={PublishFormSchema}
|
|
||||||
formData={testFormData}
|
|
||||||
uiSchema={PublishFormUiSchema}
|
|
||||||
onChange={() => null}
|
|
||||||
onSubmit={() => null}
|
|
||||||
onError={() => null}
|
|
||||||
>
|
|
||||||
Hello
|
|
||||||
</Form>
|
|
||||||
)
|
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('transformErrors() passes through data', () => {
|
|
||||||
const errorsMock = [
|
|
||||||
{
|
|
||||||
message: 'Hello',
|
|
||||||
name: 'Hello',
|
|
||||||
params: 'Hello',
|
|
||||||
property: 'Hello',
|
|
||||||
stack: 'Hello'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const error = transformErrors(errorsMock)
|
|
||||||
expect(error[0].message).toBe('Hello')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('transformErrors() transforms data', () => {
|
|
||||||
const errorsMock = [
|
|
||||||
{
|
|
||||||
message: 'Hello',
|
|
||||||
name: 'Hello',
|
|
||||||
params: 'Hello',
|
|
||||||
property: '.termsAndConditions',
|
|
||||||
stack: 'Hello'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const error = transformErrors(errorsMock)
|
|
||||||
expect(error[0].message).not.toBe('Hello')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Form data is correctly transformed to asset MetaData', () => {
|
it('Form data is correctly transformed to asset MetaData', () => {
|
||||||
const data: PublishFormDataInterface = publishFormData
|
const data: MetaDataPublishForm = publishFormData
|
||||||
let metadata: MetaDataMarket = transformPublishFormToMetadata(data)
|
let metadata: MetaDataMarket = transformPublishFormToMetadata(data)
|
||||||
|
|
||||||
expect(metadata.additionalInformation).toBeDefined()
|
expect(metadata.additionalInformation).toBeDefined()
|
||||||
expect(metadata.main).toBeDefined()
|
expect(metadata.main).toBeDefined()
|
||||||
|
|
||||||
data.price = 1.3
|
data.price = '1.3'
|
||||||
data.dateRange = '["2020-03-05T15:17:31Z","2020-03-10T16:00:00Z"]'
|
|
||||||
|
|
||||||
metadata = transformPublishFormToMetadata(data)
|
metadata = transformPublishFormToMetadata(data)
|
||||||
expect(metadata.main.price).toBe('1300000000000000000')
|
expect(metadata.main.price).toBe('1300000000000000000')
|
||||||
expect(metadata.additionalInformation.dateRange).toEqual([
|
|
||||||
'2020-03-05T15:17:31Z',
|
|
||||||
'2020-03-10T16:00:00Z'
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user