-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign Latest Addition List (#418)
* add "latest" parameter * redesign latest transliterations * update latest transliteration test * relocate queryItemOf * update Fragmentarium test * add Record to latest * update snapshot for record * remove deprecated fetchLatestTransliterations * Refactoring * add ResultPageButtons tests * style record display * extend page buttons tests * minor bug fixes * refactoring
- Loading branch information
1 parent
543418b
commit 81dc2b6
Showing
24 changed files
with
12,010 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react' | ||
import { render, screen, act } from '@testing-library/react' | ||
import userEvent from '@testing-library/user-event' | ||
import { ResultPageButtons } from './ResultPageButtons' | ||
import { queryItemFactory } from 'test-support/query-item-factory' | ||
|
||
const setActive = jest.fn() | ||
|
||
async function renderPages(numberOfPages: number, active = 0) { | ||
const pages = Array.from({ length: numberOfPages }, () => | ||
queryItemFactory.buildList(3) | ||
) | ||
await act(async () => { | ||
render( | ||
<ResultPageButtons pages={pages} active={active} setActive={setActive} /> | ||
) | ||
}) | ||
} | ||
|
||
describe('ResultPageButtons for few pages', () => { | ||
beforeEach(() => renderPages(3)) | ||
|
||
it('renders pagination buttons correctly', () => { | ||
const pagination = screen.getByLabelText('result-pagination') | ||
expect(pagination).toBeInTheDocument() | ||
expect(screen.getByText('1')).toBeVisible() | ||
expect(screen.getByText('3')).toBeVisible() | ||
expect(screen.queryByText('…')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('triggers setActive when clicking on pagination buttons', () => { | ||
const paginationItem = screen.getByText('1') | ||
userEvent.click(paginationItem) | ||
|
||
expect(setActive).toHaveBeenCalledWith(0) | ||
}) | ||
}) | ||
|
||
describe('ResultPageButtons for many pages', () => { | ||
beforeEach(() => renderPages(15, 4)) | ||
|
||
it('renders pagination buttons correctly', () => { | ||
const pagination = screen.getByLabelText('result-pagination') | ||
expect(pagination).toBeInTheDocument() | ||
expect(screen.getByText('1')).toBeVisible() | ||
expect(screen.getByText('15')).toBeVisible() | ||
expect(screen.getByText('…')).toBeVisible() | ||
}) | ||
|
||
it('shows ellipsis when page 7 is active', () => { | ||
const paginationItem = screen.getByText('7') | ||
userEvent.click(paginationItem) | ||
|
||
expect(setActive).toHaveBeenCalledWith(6) | ||
expect(screen.getByText('…')).toBeVisible() | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.SubsectionHeading--indented { | ||
padding-left: 2em; | ||
margin-bottom: 1rem; | ||
} |
Oops, something went wrong.