/**
 * Unit Tests for JWT Hooks
 *
 * Tests hook behavior in isolation (no backend required).
 */

import { renderHook } from '@testing-library/react'
import { ReactNode } from 'react'
import { JWTContext, useJWTReady } from '../JWTContext'

// Wrapper that provides JWTContext
function createWrapper(config?: Parameters<typeof JWTContext>[0]['config']) {
    return function Wrapper({ children }: { children: ReactNode }) {
        return (
            <JWTContext config={{ autoObtain: false, ...config }}>
                {children}
            </JWTContext>
        )
    }
}

describe('useJWTReady', () => {
    it('returns false outside JWTContext', () => {
        const { result } = renderHook(() => useJWTReady())
        expect(result.current).toBe(false)
    })

    it('returns false when no tokens', () => {
        const { result } = renderHook(() => useJWTReady(), {
            wrapper: createWrapper(),
        })
        expect(result.current).toBe(false)
    })
})
