mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
0eb6c15cda
* handle to many results * update search test * get transaction history based on ddo chainId * revert last commit * changed title and description * reduce paragraphs * added constant for maximum number of pages
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import React from 'react'
|
|
import { render, fireEvent } from '@testing-library/react'
|
|
import Search from '../../../src/components/templates/Search'
|
|
import {
|
|
createHistory,
|
|
createMemorySource,
|
|
LocationProvider
|
|
} from '@reach/router'
|
|
|
|
describe('Search', () => {
|
|
it('renders without crashing', async () => {
|
|
const history = createHistory(createMemorySource('/search?text=water'))
|
|
const setTotalResults = (totalResults: number) => {
|
|
const results = totalResults
|
|
}
|
|
|
|
const setTotalPagesNumber = (totalPages: number) => {
|
|
const pages = totalPages
|
|
}
|
|
|
|
const { container } = render(
|
|
<LocationProvider history={history}>
|
|
<Search
|
|
location={{ search: '?text=water' } as any}
|
|
setTotalPagesNumber={(totalPages) => setTotalPagesNumber(totalPages)}
|
|
setTotalResults={(totalResults) => setTotalResults(totalResults)}
|
|
/>
|
|
</LocationProvider>
|
|
)
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
|
|
// interact with search bar
|
|
const form = container.querySelector('form')
|
|
const input = container.querySelector('form input')
|
|
const button = container.querySelector('form button')
|
|
|
|
input &&
|
|
fireEvent.change(input, {
|
|
target: {
|
|
value: 'Changed Hello'
|
|
}
|
|
})
|
|
|
|
button && fireEvent.click(button)
|
|
form && fireEvent.submit(form)
|
|
})
|
|
})
|