-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
225 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react'; | ||
|
||
import {noop} from 'lodash'; | ||
|
||
import {render, screen} from '../../../../test-utils/utils'; | ||
import {Pagination} from '../Pagination'; | ||
import {PaginationQa, getPaginationPageQa} from '../constants'; | ||
|
||
describe('Pagination component', () => { | ||
test('Single page', () => { | ||
render(<Pagination pageSize={20} total={20} onUpdate={noop} page={0} />); | ||
|
||
const firstButton = screen.getByTestId(PaginationQa.PaginationButtonFirst); | ||
expect(firstButton).toBeDisabled(); | ||
|
||
const prevButton = screen.getByTestId(PaginationQa.PaginationButtonPrevious); | ||
expect(prevButton).toBeDisabled(); | ||
|
||
const nextButton = screen.getByTestId(PaginationQa.PaginationButtonNext); | ||
expect(nextButton).toBeDisabled(); | ||
}); | ||
|
||
describe('Two pages', () => { | ||
const PAGE_SIZE = 20; | ||
const TOTAL = PAGE_SIZE + 1; | ||
|
||
const FIRST_PAGE = 1; | ||
const SECOND_PAGE = 2; | ||
|
||
test('First page is current', () => { | ||
render( | ||
<Pagination pageSize={PAGE_SIZE} total={TOTAL} onUpdate={noop} page={FIRST_PAGE} />, | ||
); | ||
|
||
const firstPageButton = screen.getByTestId(getPaginationPageQa(FIRST_PAGE)); | ||
expect(firstPageButton).toHaveAttribute('aria-pressed', 'true'); | ||
|
||
const secondPageButton = screen.getByTestId(getPaginationPageQa(SECOND_PAGE)); | ||
expect(secondPageButton).toHaveAttribute('aria-pressed', 'false'); | ||
|
||
const firstButton = screen.getByTestId(PaginationQa.PaginationButtonFirst); | ||
expect(firstButton).toBeDisabled(); | ||
|
||
const prevButton = screen.getByTestId(PaginationQa.PaginationButtonPrevious); | ||
expect(prevButton).toBeDisabled(); | ||
|
||
const nextButton = screen.getByTestId(PaginationQa.PaginationButtonNext); | ||
expect(nextButton).not.toBeDisabled(); | ||
}); | ||
|
||
test('Second page is current', () => { | ||
render( | ||
<Pagination | ||
pageSize={PAGE_SIZE} | ||
total={TOTAL} | ||
onUpdate={noop} | ||
page={SECOND_PAGE} | ||
/>, | ||
); | ||
|
||
const firstPageButton = screen.getByTestId(getPaginationPageQa(FIRST_PAGE)); | ||
expect(firstPageButton).toHaveAttribute('aria-pressed', 'false'); | ||
|
||
const secondPageButton = screen.getByTestId(getPaginationPageQa(SECOND_PAGE)); | ||
expect(secondPageButton).toHaveAttribute('aria-pressed', 'true'); | ||
|
||
const firstButton = screen.getByTestId(PaginationQa.PaginationButtonFirst); | ||
expect(firstButton).not.toBeDisabled(); | ||
|
||
const prevButton = screen.getByTestId(PaginationQa.PaginationButtonPrevious); | ||
expect(prevButton).not.toBeDisabled(); | ||
|
||
const nextButton = screen.getByTestId(PaginationQa.PaginationButtonNext); | ||
expect(nextButton).toBeDisabled(); | ||
}); | ||
}); | ||
|
||
test('Total property undefined', () => { | ||
render(<Pagination pageSize={20} onUpdate={noop} page={0} total={undefined} />); | ||
|
||
const nextButton = screen.getByTestId(PaginationQa.PaginationButtonNext); | ||
|
||
expect(nextButton).not.toBeDisabled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.