Files
Nitro-V3/src/hooks/navigator/useNavigatorStore.test.tsx
T
simoleo89 ee3736474d refactor(navigator): remove search ownership from useNavigatorStore
P2 core surgery: search result + NavigatorSearchEvent listener +
sendSearch + reloadCurrentSearch all leave useNavigatorStore. The new
useNavigatorSearch query hook owns the cache. useNavigatorActions is
deleted entirely — the only two actions it exposed are gone, and no
consumer outside Navigator depended on it.

NavigatorMetadataEvent handler now seeds the UI store's currentTabCode
on first arrival, activating the query the moment top-level contexts
land.

useNavigatorData: searchResult removed from closure and return.
useNavigatorUiState: currentTabCode + currentFilter added.
index.ts: useNavigatorActions removed, useNavigatorSearch added.

NavigatorView.tsx is intentionally broken at this commit and gets
fixed in the next.
2026-05-27 19:20:27 +02:00

28 lines
1.0 KiB
TypeScript

import { renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { useNavigatorData, useNavigatorUiState } from './index';
describe('navigator filter shapes (smoke)', () =>
{
it('useNavigatorData returns the documented keys', () =>
{
const { result } = renderHook(() => useNavigatorData());
expect(Object.keys(result.current).sort()).toEqual([
'categories', 'eventCategories', 'favouriteRoomIds',
'navigatorData', 'navigatorSearches',
'topLevelContext', 'topLevelContexts'
].sort());
});
it('useNavigatorUiState returns the 11 documented flags', () =>
{
const { result } = renderHook(() => useNavigatorUiState());
expect(Object.keys(result.current).sort()).toEqual([
'currentFilter', 'currentTabCode',
'isCreatorOpen', 'isLoading', 'isOpenSavesSearches',
'isReady', 'isRoomInfoOpen', 'isRoomLinkOpen', 'isVisible',
'needsInit', 'needsSearch'
].sort());
});
});