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:
Felipe Cardoso
2025-11-03 14:35:21 +01:00
parent 852c7eceff
commit 4bf34ea287
2 changed files with 26 additions and 24 deletions

View File

@@ -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