mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
30 lines
949 B
TypeScript
30 lines
949 B
TypeScript
import React from 'react'
|
|
import { render, fireEvent, waitForElement, act } from '@testing-library/react'
|
|
import Ipfs from '.'
|
|
|
|
const addFile = jest.fn()
|
|
|
|
describe('IPFS', () => {
|
|
const ui = <Ipfs addFile={addFile} />
|
|
const file = new File(['(⌐□_□)'], 'chucknorris.png', {
|
|
type: 'image/png'
|
|
})
|
|
|
|
it('HTTP API: files can be dropped', async () => {
|
|
const { container, getByText } = render(ui)
|
|
expect(container).toBeInTheDocument()
|
|
|
|
// wait for IPFS node
|
|
await waitForElement(() => getByText(/Connected to /))
|
|
|
|
// drop a file
|
|
const dropzoneInput = container.querySelector('.dropzone')
|
|
Object.defineProperty(dropzoneInput, 'files', { value: [file] })
|
|
act(() => {
|
|
dropzoneInput && fireEvent.drop(dropzoneInput)
|
|
})
|
|
const addingText = await waitForElement(() => getByText(/Adding /))
|
|
expect(addingText).toBeDefined()
|
|
})
|
|
})
|