1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fix text and added ipfs and arweave tests

This commit is contained in:
EnzoVezzaro 2022-11-14 12:17:29 -04:00
parent 1649e075e2
commit 23d8002ce8

View File

@ -52,12 +52,13 @@ describe('@shared/FormInput/InputElement/FilesInput', () => {
{ {
valid: true, valid: true,
url: 'https://hello.com', url: 'https://hello.com',
type: 'url',
contentType: 'text/html', contentType: 'text/html',
contentLength: 100 contentLength: 100
} }
]) ])
render(<FilesInput form={mockForm} {...props} />) render(<FilesInput form={mockForm} field={mockField} {...props} />)
expect(screen.getByText('Validate')).toBeInTheDocument() expect(screen.getByText('Validate')).toBeInTheDocument()
fireEvent.click(screen.getByText('Validate')) fireEvent.click(screen.getByText('Validate'))
@ -67,13 +68,14 @@ describe('@shared/FormInput/InputElement/FilesInput', () => {
expect(mockHelpers.setValue).toHaveBeenCalled() expect(mockHelpers.setValue).toHaveBeenCalled()
}) })
it('renders fileinfo when file is valid', () => { it('renders fileinfo when file url is valid', () => {
;(useField as jest.Mock).mockReturnValue([ ;(useField as jest.Mock).mockReturnValue([
{ {
value: [ value: [
{ {
valid: true, valid: true,
url: 'https://hello.com', url: 'https://hello.com',
type: 'url',
contentType: 'text/html', contentType: 'text/html',
contentLength: 100 contentLength: 100
} }
@ -82,10 +84,52 @@ describe('@shared/FormInput/InputElement/FilesInput', () => {
mockMeta, mockMeta,
mockHelpers mockHelpers
]) ])
render(<FilesInput {...props} />) render(<FilesInput {...props} field={mockField} />)
expect(screen.getByText('https://hello.com')).toBeInTheDocument() expect(screen.getByText('https://hello.com')).toBeInTheDocument()
}) })
it('renders fileinfo when ipfs is valid', () => {
;(useField as jest.Mock).mockReturnValue([
{
value: [
{
valid: true,
hash: 'bafkreicxccbk4blsx5qtovqfgsuutxjxom47dvyzyz3asi2ggjg5ipwlc4',
type: 'ipfs',
contentLength: '40492',
contentType: 'text/csv',
index: 0
}
]
},
mockMeta,
mockHelpers
])
render(<FilesInput {...props} field={mockField} />)
expect(screen.getByText('✓ URL confirmed')).toBeInTheDocument()
})
it('renders fileinfo when arweave is valid', () => {
;(useField as jest.Mock).mockReturnValue([
{
value: [
{
valid: true,
transactionId: 'T6NL8Zc0LCbT3bF9HacAGQC4W0_hW7b3tXbm8OtWtlA',
type: 'arweave',
contentLength: '57043',
contentType: 'image/jpeg',
index: 0
}
]
},
mockMeta,
mockHelpers
])
render(<FilesInput {...props} field={mockField} />)
expect(screen.getByText('✓ URL confirmed')).toBeInTheDocument()
})
it('renders fileinfo without contentType', () => { it('renders fileinfo without contentType', () => {
;(useField as jest.Mock).mockReturnValue([ ;(useField as jest.Mock).mockReturnValue([
{ {
@ -100,7 +144,7 @@ describe('@shared/FormInput/InputElement/FilesInput', () => {
mockMeta, mockMeta,
mockHelpers mockHelpers
]) ])
render(<FilesInput {...props} />) render(<FilesInput {...props} field={mockField} />)
}) })
it('renders fileinfo placeholder when hideUrl is passed', () => { it('renders fileinfo placeholder when hideUrl is passed', () => {
@ -117,7 +161,7 @@ describe('@shared/FormInput/InputElement/FilesInput', () => {
mockMeta, mockMeta,
mockHelpers mockHelpers
]) ])
render(<FilesInput {...props} />) render(<FilesInput {...props} field={mockField} />)
expect( expect(
screen.getByText('https://oceanprotocol/placeholder') screen.getByText('https://oceanprotocol/placeholder')
).toBeInTheDocument() ).toBeInTheDocument()