Update tests to replace useAuthStore with useAuth from AuthContext
- Replaced legacy `useAuthStore` mocks with `useAuth` for consistency with the `AuthContext` pattern. - Updated test cases in `Header` and `AuthGuard` to mock `AuthContext` instead of Zustand hooks. - Improved test isolation by injecting `AuthProvider` where applicable.
This commit is contained in:
@@ -18,7 +18,7 @@ jest.mock('next/navigation', () => ({
|
||||
usePathname: () => mockPathname,
|
||||
}));
|
||||
|
||||
// Mock auth store
|
||||
// Mock auth state via Context
|
||||
let mockAuthState: {
|
||||
isAuthenticated: boolean;
|
||||
isLoading: boolean;
|
||||
@@ -29,8 +29,9 @@ let mockAuthState: {
|
||||
user: null,
|
||||
};
|
||||
|
||||
jest.mock('@/lib/stores/authStore', () => ({
|
||||
useAuthStore: () => mockAuthState,
|
||||
jest.mock('@/lib/auth/AuthContext', () => ({
|
||||
useAuth: () => mockAuthState,
|
||||
AuthProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
// Mock useMe hook
|
||||
|
||||
Reference in New Issue
Block a user