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

30 lines
900 B
TypeScript
Raw Normal View History

2020-05-07 08:03:30 +02:00
import React from 'react'
import { render, fireEvent } from '@testing-library/react'
import Pagination from '../../../src/components/molecules/Pagination'
const defaultProps = {
hrefBuilder: () => null as any,
onPageChange: () => null as any
}
describe('Pagination', () => {
it('renders without crashing', () => {
const { getByText, container } = render(
<Pagination totalPages={20} currentPage={1} {...defaultProps} />
)
expect(container.firstChild).toBeInTheDocument()
container.firstChild && expect(container.firstChild.nodeName).toBe('UL')
// interact with page links
const pageLink = getByText('2')
fireEvent.click(pageLink)
})
it('renders nothing when no pages', () => {
const { container } = render(
<Pagination totalPages={1} currentPage={1} {...defaultProps} />
)
expect(container.firstChild).not.toBeInTheDocument()
})
})