🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { act, renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { useImeAwareQuery } from './useImeAwareQuery';
describe('useImeAwareQuery', () => {
it('follows plain typing immediately', () => {
const { result } = renderHook(() => useImeAwareQuery());
act(() => result.current.inputProps.onInputChange('api'));
expect(result.current.query).toBe('api');
expect(result.current.inputProps.value).toBe('api');
});
it('holds the query during IME composition and commits on compositionend', () => {
const { result } = renderHook(() => useImeAwareQuery());
act(() => {
result.current.inputProps.onCompositionStart();
result.current.inputProps.onInputChange("yu'y");
});
expect(result.current.inputProps.value).toBe("yu'y");
expect(result.current.query).toBe('');
// Chrome order: final input event, then compositionend
act(() => {
result.current.inputProps.onInputChange('è¯è¨€');
result.current.inputProps.onCompositionEnd({ currentTarget: { value: 'è¯è¨€' } });
});
expect(result.current.query).toBe('è¯è¨€');
});
it('commits when compositionend fires before the final input event (Safari)', () => {
const { result } = renderHook(() => useImeAwareQuery());
act(() => {
result.current.inputProps.onCompositionStart();
result.current.inputProps.onInputChange('she');
result.current.inputProps.onCompositionEnd({ currentTarget: { value: '设置' } });
result.current.inputProps.onInputChange('设置');
});
expect(result.current.query).toBe('设置');
});
});