Skip to content

Commit 4ce6e0e

Browse files
committed
test: improve test coverage for fileTreeSlice
1 parent 6342f28 commit 4ce6e0e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎packages/frontend/test/unit/store/fileTreeSlice.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ describe('fileTreeSlice', () => {
147147
expect(store.getState().fileTree.mountedDirectoryPath).toEqual('/new/path');
148148
});
149149

150+
it('should remove the oldest expanded node cache when recent paths exceed the limit', () => {
151+
const paths = Array.from({ length: 11 }, (_, index) => `/test/path-${index + 1}`);
152+
153+
paths.forEach((path, index) => {
154+
store.dispatch(setMountedDirectoryPath(path));
155+
store.dispatch(setExpandedNodes([`node-${index + 1}`]));
156+
});
157+
158+
expect(localStorage.getItem('mdts_expanded_nodes_/test/path-1')).toBeNull();
159+
expect(localStorage.getItem('mdts_expanded_nodes_/test/path-11')).toEqual(JSON.stringify(['node-11']));
160+
expect(localStorage.getItem('mdts_recent_paths')).toEqual(JSON.stringify(paths.slice(1).reverse()));
161+
});
162+
150163
describe('fetchFileTree async thunk', () => {
151164
it('should handle pending state', () => {
152165
store.dispatch(fetchFileTree.pending('requestId', undefined));

0 commit comments

Comments
 (0)