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 {
2020-07-16 13:39:02 +02:00
MetadataMarket,
MetadataPublishForm
} from '../../../src/@types/Metadata'
2020-07-10 13:19:04 +02:00
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()
})
2020-07-16 13:39:02 +02:00
it('Form data is correctly transformed to asset Metadata', () => {
const data: MetadataPublishForm = publishFormData
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')
})
})