mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
test: enhance ClaudeUsageService tests with promise handling and exit callback
- Added an `afterEach` hook to clean up after tests in `claude-usage-service.test.ts`. - Updated the mock for `onExit` to include an exit callback, ensuring proper handling of process termination. - Modified the `fetchUsageData` test to await the promise resolution, preventing unhandled promise rejections. These changes improve the reliability and robustness of the unit tests for the ClaudeUsageService.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
interface UseSidebarAutoCollapseProps {
|
||||
sidebarOpen: boolean;
|
||||
@@ -9,6 +9,8 @@ export function useSidebarAutoCollapse({
|
||||
sidebarOpen,
|
||||
toggleSidebar,
|
||||
}: UseSidebarAutoCollapseProps) {
|
||||
const isMountedRef = useRef(false);
|
||||
|
||||
// Auto-collapse sidebar on small screens
|
||||
useEffect(() => {
|
||||
const mediaQuery = window.matchMedia('(max-width: 1024px)'); // lg breakpoint
|
||||
@@ -20,8 +22,11 @@ export function useSidebarAutoCollapse({
|
||||
}
|
||||
};
|
||||
|
||||
// Check on mount
|
||||
handleResize();
|
||||
// Check on mount only
|
||||
if (!isMountedRef.current) {
|
||||
isMountedRef.current = true;
|
||||
handleResize();
|
||||
}
|
||||
|
||||
// Listen for changes
|
||||
mediaQuery.addEventListener('change', handleResize);
|
||||
|
||||
Reference in New Issue
Block a user