import { renderHook } from '@testing-library/react' import useSetUpFocus from '../useSetUpFocus' import { SetUpProgress } from '../useSetUpProgress' const renderFocus = (progressOnArrival: SetUpProgress) => renderHook(({ progress }) => useSetUpFocus(progress), { initialProps: { progress: progressOnArrival }, }) describe('useSetUpFocus', () => { it('focuses on nothing while the progress is loading', () => { expect(renderFocus('loading').result.current).toBe('loading') }) it('focuses on the set-up until the plugin is connected', () => { expect(renderFocus('notConnected').result.current).toBe('setUp') }) it('cannot decide when the progress could not be checked', () => { expect(renderFocus('failed').result.current).toBe('failed') }) it('focuses on daily use when the set-up was complete on arrival', () => { expect(renderFocus('complete').result.current).toBe('dailyUse') }) it('keeps the focus on the set-up for the rest of the visit once connected', () => { const { result, rerender } = renderFocus('notConnected') rerender({ progress: 'complete' }) expect(result.current).toBe('setUp') }) it('cannot decide when checking the progress fails later in the visit', () => { const { result, rerender } = renderFocus('notConnected') rerender({ progress: 'failed' }) expect(result.current).toBe('failed') }) it('follows the first known progress, not the loading before it', () => { const { result, rerender } = renderFocus('loading') rerender({ progress: 'complete' }) expect(result.current).toBe('dailyUse') }) })