-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The old approach did not work because navigating to a new document would re-render the tree. We now try to hold that state in Zustand so it can be persisted across navigations
- Loading branch information
1 parent
bc46713
commit ba7494a
Showing
12 changed files
with
244 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
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
32 changes: 32 additions & 0 deletions
32
packages/web-ui/src/sections/Document/Sidebar/Files/useOpenPaths/index.test.ts
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,32 @@ | ||
import { act, renderHook } from '@testing-library/react' | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { useOpenPaths } from './index' | ||
|
||
describe('useOpenPaths', () => { | ||
it('shout add the paths', async () => { | ||
const { result } = renderHook(() => useOpenPaths((state) => state)) | ||
act(() => { | ||
result.current.togglePath('some-folder/nested-folder/doc1') | ||
}) | ||
|
||
expect(result.current.openPaths).toEqual([ | ||
'', | ||
'some-folder', | ||
'some-folder/nested-folder', | ||
'some-folder/nested-folder/doc1', | ||
]) | ||
}) | ||
|
||
it('shout remove nested paths', async () => { | ||
const { result } = renderHook(() => useOpenPaths((state) => state)) | ||
act(() => { | ||
result.current.togglePath('some-folder/nested-folder/doc1') | ||
}) | ||
|
||
act(() => { | ||
result.current.togglePath('some-folder/nested-folder') | ||
}) | ||
expect(result.current.openPaths).toEqual(['', 'some-folder']) | ||
}) | ||
}) |
Oops, something went wrong.