testing ADR - architectural decisions
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Has been cancelled
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Has been cancelled
This commit is contained in:
@@ -59,22 +59,14 @@ describe('useAuth Hook and AuthProvider', () => {
|
||||
console.error = originalError;
|
||||
});
|
||||
|
||||
it('initializes with a "Determining..." state and isLoading as true', async () => {
|
||||
// Use fake timers to control async operations and prevent useEffect from running immediately.
|
||||
vi.useFakeTimers();
|
||||
|
||||
it('initializes with a "Determining..." state and isLoading as true', () => {
|
||||
const { result } = renderHook(() => useAuth(), { wrapper });
|
||||
|
||||
// At this point, the component has rendered with its initial state,
|
||||
// but the useEffect has been queued and not yet executed.
|
||||
// Immediately after the initial render, before the useEffect has resolved,
|
||||
// the state should be in its initial "Determining..." phase.
|
||||
expect(result.current.authStatus).toBe('Determining...');
|
||||
expect(result.current.isLoading).toBe(true);
|
||||
expect(result.current.user).toBeNull();
|
||||
|
||||
// Allow promises to resolve and timers to run to avoid leaving the test in a pending state.
|
||||
await act(async () => {
|
||||
vi.runAllTimers();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Initial Auth Check (useEffect)', () => {
|
||||
|
||||
Reference in New Issue
Block a user