-
Notifications
You must be signed in to change notification settings - Fork 3
YPE-2256: abstract BibleChapterPicker content + override #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cameronapak
merged 6 commits into
main
from
YPE-2256-react-sdk-abstract-bible-chapter-picker-content-view-for-rn-expo-sdk
May 5, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1538f82
feat(ui): export BibleChapterPicker.Content and add onChapterPickerPr…
Dustin-Kelley 13a3dee
fix(ui): update default value handling in BibleChapterPicker.Content …
Dustin-Kelley 032087f
fix(ui): ensure scrollToCurrentBook is called when onChapterPickerPre…
Dustin-Kelley 4e4036f
fix(ui): scroll style overflow
Dustin-Kelley cd5013a
feat(hooks): Add exclude to vitest config
cameronapak de4d87f
Fix scrolling and default book in Bible Chapter Picker
cameronapak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| --- | ||
| "@youversion/platform-react-ui": minor | ||
| --- | ||
|
|
||
| Export `BibleChapterPicker.Content` for standalone rendering and add `onChapterPickerPress` to intercept trigger presses (e.g. to render picker content in a native bottom sheet instead of a popover). | ||
|
|
This file contains hidden or 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
117 changes: 117 additions & 0 deletions
117
packages/ui/src/components/bible-chapter-picker.test.tsx
This file contains hidden or 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,117 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| // We stub ResizeObserver for jsdom (used by Radix/@floating-ui). The stub methods are intentionally no-ops. | ||
| /* eslint-disable @typescript-eslint/no-empty-function */ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
|
|
||
| // ResizeObserver is used by @floating-ui/dom (Radix Popover) | ||
| class ResizeObserverMock { | ||
| observe() {} | ||
| unobserve() {} | ||
| disconnect() {} | ||
| } | ||
| globalThis.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver; | ||
|
|
||
| import { BibleChapterPicker } from './bible-chapter-picker'; | ||
| import { useBooks, useTheme } from '@youversion/platform-react-hooks'; | ||
| import type { BibleBook } from '@youversion/platform-core'; | ||
|
|
||
| vi.mock('@youversion/platform-react-hooks'); | ||
|
|
||
| const mockBooks: BibleBook[] = [ | ||
| { | ||
| id: 'GEN', | ||
| title: 'Genesis', | ||
| full_title: 'The First Book of Moses, Commonly Called Genesis', | ||
| canon: 'old_testament', | ||
| abbreviation: 'Gen', | ||
| intro: { id: 'INTRO', passage_id: 'GEN.0.INTRO', title: 'Intro' }, | ||
| chapters: [ | ||
| { id: '1', title: '1', passage_id: 'GEN.1' }, | ||
| { id: '2', title: '2', passage_id: 'GEN.2' }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| function setupDefaultMocks() { | ||
| vi.mocked(useTheme).mockReturnValue('light'); | ||
| vi.mocked(useBooks).mockReturnValue({ | ||
| books: { data: [...mockBooks], next_page_token: null }, | ||
| loading: false, | ||
| error: null, | ||
| refetch: vi.fn(), | ||
| }); | ||
| } | ||
|
|
||
| describe('BibleChapterPicker - onChapterPickerPress override', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| setupDefaultMocks(); | ||
| }); | ||
|
|
||
| it('calls onChapterPickerPress with { book, chapter, versionId } when Trigger is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| const onChapterPickerPress = vi.fn(); | ||
|
|
||
| render( | ||
| <BibleChapterPicker.Root | ||
| versionId={3034} | ||
| book="GEN" | ||
| chapter="1" | ||
| onChapterPickerPress={onChapterPickerPress} | ||
| > | ||
| <BibleChapterPicker.Trigger /> | ||
| </BibleChapterPicker.Root>, | ||
| ); | ||
|
|
||
| await user.click(screen.getByRole('button')); | ||
|
|
||
| expect(onChapterPickerPress).toHaveBeenCalledTimes(1); | ||
| expect(onChapterPickerPress).toHaveBeenCalledWith({ | ||
| book: 'GEN', | ||
| chapter: '1', | ||
| versionId: 3034, | ||
| }); | ||
| }); | ||
|
|
||
| it('does NOT render popover content when onChapterPickerPress is provided', () => { | ||
| render( | ||
| <BibleChapterPicker.Root | ||
| versionId={3034} | ||
| book="GEN" | ||
| chapter="1" | ||
| onChapterPickerPress={vi.fn()} | ||
| > | ||
| <BibleChapterPicker.Trigger /> | ||
| </BibleChapterPicker.Root>, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Books')).not.toBeInTheDocument(); | ||
| expect(screen.queryByPlaceholderText('Search')).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('BibleChapterPicker - default popover mode', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| setupDefaultMocks(); | ||
| }); | ||
|
|
||
| it('renders popover content when Trigger is clicked and no override is provided', async () => { | ||
| const user = userEvent.setup(); | ||
|
|
||
| render( | ||
| <BibleChapterPicker.Root versionId={3034} book="GEN" chapter="1"> | ||
| <BibleChapterPicker.Trigger /> | ||
| </BibleChapterPicker.Root>, | ||
| ); | ||
|
|
||
| await user.click(screen.getByRole('button')); | ||
|
|
||
| expect(await screen.findByText('Books')).toBeInTheDocument(); | ||
| expect(await screen.findByPlaceholderText('Search')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.