1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00
market/tests/unit/components/PublishForm.test.tsx

31 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-05-07 08:03:30 +02:00
import React from 'react'
import { render } from '@testing-library/react'
2020-07-10 12:09:43 +02:00
import { transformPublishFormToMetadata } from '../../../src/components/pages/Publish/utils'
2020-07-10 13:19:04 +02:00
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'
2020-05-07 08:03:30 +02:00
describe('PublishForm', () => {
it('renders without crashing', async () => {
2020-07-10 13:19:04 +02:00
const { container } = render(<PublishForm content={content.form} />)
2020-05-07 08:03:30 +02:00
expect(container.firstChild).toBeInTheDocument()
})
it('Form data is correctly transformed to asset MetaData', () => {
2020-07-10 13:19:04 +02:00
const data: MetaDataPublishForm = publishFormData
2020-06-02 11:15:21 +02:00
let metadata: MetaDataMarket = transformPublishFormToMetadata(data)
2020-05-07 08:03:30 +02:00
expect(metadata.additionalInformation).toBeDefined()
expect(metadata.main).toBeDefined()
2020-07-10 13:19:04 +02:00
data.price = '1.3'
2020-05-07 08:03:30 +02:00
metadata = transformPublishFormToMetadata(data)
expect(metadata.main.price).toBe('1300000000000000000')
})
})