-
Notifications
You must be signed in to change notification settings - Fork 33
feat: Add ObjectFetcher context and useObjectFetcher hook #1753
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
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7fe24cd
feat: Add ObjectFetcher context and useObjectFetcher hook
mofojed 944ba48
Fix up useDeferredApi tests
mofojed df3e2a1
Cleanup based on review
mofojed 67f6955
Clean up typing a bit
mofojed 77a0b00
Clean up based on review
mofojed 94d29f3
WIP just ripping off the band-aid
mofojed 6a7af1e
Clean up object fetcher
mofojed 443993f
Clean up types some more, fix up code
mofojed a0b5fc2
Don't have a Partial on PanelEvent
mofojed 982c619
Clean up based on review
mofojed 35a9b2e
Fix up types on ObjectFetcher
mofojed d94642e
Merge remote-tracking branch 'origin/main' into object-fetcher
mofojed d258f74
Remove the unnecessary extra typing
mofojed 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
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
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
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
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
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
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
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
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,34 @@ | ||
| import { act, renderHook } from '@testing-library/react-hooks'; | ||
| import { useContext } from 'react'; | ||
| import { TestUtils } from '@deephaven/utils'; | ||
| import { useObjectFetcher } from './useObjectFetcher'; | ||
|
|
||
| const { asMock, flushPromises } = TestUtils; | ||
|
|
||
| jest.mock('react', () => ({ | ||
| ...jest.requireActual('react'), | ||
| useContext: jest.fn(), | ||
| })); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| asMock(useContext).mockName('useContext'); | ||
| }); | ||
|
|
||
| it('should resolve the fetcher when set in the context', async () => { | ||
| const fetcher = jest.fn(async () => undefined); | ||
| asMock(useContext).mockReturnValue(fetcher); | ||
|
|
||
| const { result } = renderHook(() => useObjectFetcher()); | ||
| await act(flushPromises); | ||
| expect(result.current).toEqual(fetcher); | ||
| expect(result.error).toBeUndefined(); | ||
| expect(fetcher).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('throws an error if the context is null', async () => { | ||
|
mofojed marked this conversation as resolved.
|
||
| asMock(useContext).mockReturnValue(null); | ||
|
|
||
| const { result } = renderHook(() => useObjectFetcher()); | ||
| expect(result.error).not.toBeNull(); | ||
| }); | ||
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.