2025-11-05 16:20:04 -08:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2026-02-03 17:08:10 -08:00
|
|
|
import { renderWithProviders } from '../../test-utils/render.js';
|
|
|
|
|
import { createMockSettings } from '../../test-utils/settings.js';
|
2025-11-05 16:20:04 -08:00
|
|
|
import { CliSpinner } from './CliSpinner.js';
|
|
|
|
|
import { debugState } from '../debug.js';
|
|
|
|
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
|
|
|
|
|
|
|
|
describe('<CliSpinner />', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
debugState.debugNumAnimatedComponents = 0;
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-18 16:46:50 -08:00
|
|
|
it('should increment debugNumAnimatedComponents on mount and decrement on unmount', async () => {
|
2025-11-05 16:20:04 -08:00
|
|
|
expect(debugState.debugNumAnimatedComponents).toBe(0);
|
2026-02-18 16:46:50 -08:00
|
|
|
const { waitUntilReady, unmount } = renderWithProviders(<CliSpinner />);
|
|
|
|
|
await waitUntilReady();
|
2025-11-05 16:20:04 -08:00
|
|
|
expect(debugState.debugNumAnimatedComponents).toBe(1);
|
|
|
|
|
unmount();
|
|
|
|
|
expect(debugState.debugNumAnimatedComponents).toBe(0);
|
|
|
|
|
});
|
2026-01-26 16:06:58 -08:00
|
|
|
|
2026-02-18 16:46:50 -08:00
|
|
|
it('should not render when showSpinner is false', async () => {
|
2026-01-26 16:06:58 -08:00
|
|
|
const settings = createMockSettings({ ui: { showSpinner: false } });
|
2026-02-18 16:46:50 -08:00
|
|
|
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
|
|
|
|
<CliSpinner />,
|
|
|
|
|
{ settings },
|
|
|
|
|
);
|
|
|
|
|
await waitUntilReady();
|
|
|
|
|
expect(lastFrame({ allowEmpty: true })).toBe('');
|
|
|
|
|
unmount();
|
2026-01-26 16:06:58 -08:00
|
|
|
});
|
2025-11-05 16:20:04 -08:00
|
|
|
});
|