summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
diff options
context:
space:
mode:
authorAllen Hutchison <[email protected]>2025-06-03 10:12:47 -0700
committerGitHub <[email protected]>2025-06-03 10:12:47 -0700
commit72f5ec3725a71ca6b69956faba07d5e9d626bb6c (patch)
tree19726063dea6f0f725b091a5c2dfeec6beadb529 /packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
parentd9677528339aaf8b559368e4ee1b8c9d7793c293 (diff)
feat(cli): randomize and expand witty loading phrases (#704)
Diffstat (limited to 'packages/cli/src/ui/hooks/useLoadingIndicator.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/useLoadingIndicator.test.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts b/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
index c20ded88..92ae81a2 100644
--- a/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
+++ b/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { act, renderHook } from '@testing-library/react';
import { useLoadingIndicator } from './useLoadingIndicator.js';
import { StreamingState } from '../types.js';
@@ -39,15 +39,18 @@ describe('useLoadingIndicator', () => {
// Initial state before timers advance
expect(result.current.elapsedTime).toBe(0);
- expect(result.current.currentLoadingPhrase).toBe(WITTY_LOADING_PHRASES[0]);
+ expect(WITTY_LOADING_PHRASES).toContain(
+ result.current.currentLoadingPhrase,
+ );
+ const _initialPhrase = result.current.currentLoadingPhrase;
act(() => {
vi.advanceTimersByTime(PHRASE_CHANGE_INTERVAL_MS);
});
// Phrase should cycle if PHRASE_CHANGE_INTERVAL_MS has passed
- // This depends on the actual implementation of usePhraseCycler
- // For simplicity, we'll check it's one of the witty phrases
- expect(result.current.currentLoadingPhrase).toBe(WITTY_LOADING_PHRASES[1]);
+ expect(WITTY_LOADING_PHRASES).toContain(
+ result.current.currentLoadingPhrase,
+ );
});
it('should show waiting phrase and retain elapsedTime when WaitingForConfirmation', () => {
@@ -75,7 +78,7 @@ describe('useLoadingIndicator', () => {
expect(result.current.elapsedTime).toBe(60);
});
- it('should reset elapsedTime and use initial phrase when transitioning from WaitingForConfirmation to Responding', () => {
+ it('should reset elapsedTime and use a witty phrase when transitioning from WaitingForConfirmation to Responding', () => {
const { result, rerender } = renderHook(
({ streamingState }) => useLoadingIndicator(streamingState),
{ initialProps: { streamingState: StreamingState.Responding } },
@@ -94,7 +97,9 @@ describe('useLoadingIndicator', () => {
rerender({ streamingState: StreamingState.Responding });
expect(result.current.elapsedTime).toBe(0); // Should reset
- expect(result.current.currentLoadingPhrase).toBe(WITTY_LOADING_PHRASES[0]);
+ expect(WITTY_LOADING_PHRASES).toContain(
+ result.current.currentLoadingPhrase,
+ );
act(() => {
vi.advanceTimersByTime(1000);