mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* refactor: add desktop sidebar navigation and consolidate header actions - Add DesktopSidebar component with collapsible navigation - Add useDesktop and useSidebarAction hooks for sidebar state management - Add useSidebarCollapsed hook with localStorage persistence and error handling - Integrate sidebar into App layout with tooltip support - Remove repoUrl and isRepoWorktree props from SourceControlPanel - BranchesTab now fetches repo data internally using getRepo query - Remove unused to prop from SidebarItem - Simplify RepoList conditional rendering - Add comprehensive test coverage for new components * refactor: remove LSP status button and memory plugin status hook - Delete LspStatusButton component and its test file - Remove unused useMemoryPluginStatus hook from RepoDetail - Clean up dead code as part of desktop header refactor
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
import { renderHook, act } from '@testing-library/react'
|
|
import { useDesktop } from './useDesktop'
|
|
|
|
describe('useDesktop', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks()
|
|
})
|
|
|
|
it('returns true for width >= 768px', () => {
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
writable: true,
|
|
configurable: true,
|
|
value: 1024,
|
|
})
|
|
|
|
const { result } = renderHook(() => useDesktop())
|
|
|
|
expect(result.current).toBe(true)
|
|
})
|
|
|
|
it('returns false for width < 768px', () => {
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
writable: true,
|
|
configurable: true,
|
|
value: 500,
|
|
})
|
|
|
|
const { result } = renderHook(() => useDesktop())
|
|
|
|
expect(result.current).toBe(false)
|
|
})
|
|
|
|
it('updates when window is resized', () => {
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
writable: true,
|
|
configurable: true,
|
|
value: 500,
|
|
})
|
|
|
|
const { result } = renderHook(() => useDesktop())
|
|
|
|
expect(result.current).toBe(false)
|
|
|
|
act(() => {
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
writable: true,
|
|
configurable: true,
|
|
value: 1024,
|
|
})
|
|
window.dispatchEvent(new Event('resize'))
|
|
})
|
|
|
|
expect(result.current).toBe(true)
|
|
})
|
|
})
|